<?php
namespace Illuminate\Support;
use Throwable;
class Timebox
{
/**
* Indicates if the timebox is allowed to return early.
*
* @var bool
*/
public $earlyReturn = false;
/**
* Invoke the given callback within the specified timebox minimum.
*
* @template TCallReturnType
*
* @param (callable($this): TCallReturnType) $callback
* @param int $microseconds
* @return TCallReturnType
*
* @throws \Throwable
*/
public function call(callable $callback, int $microseconds)
{
$exception = null;
$start = microtime(true);
try {
$result = $callback($this);
} catch (Throwable $caught) {
$exception = $caught;
}
$remainder = intval($microseconds - ((microtime(true) - $start) * 1000000));
if (! $this->earlyReturn && $remainder > 0) {
$this->usleep($remainder);
}
if ($exception) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX