app/Services/TimeoutService.php
public function isTimeNearlyUp(float $threshold = self::TIME_UP_THRESHOLD): bool
    {
        $max_execution_time = (int) ini_get('max_execution_time');

        // If there's no time limit, then we can't run out of time.
        if ($max_execution_time === 0) {
            return false;
        }

        $now = microtime(true);

        return $now + $threshold > $this->start_time + (float) $max_execution_time;
    }
public function isTimeNearlyUp(float $threshold = self::TIME_UP_THRESHOLD): bool
    {
        $max_execution_time = (int) ini_get('max_execution_time');

        // If there's no time limit, then we can't run out of time.
        if ($max_execution_time === 0) {
            return false;
        }

        $now = microtime(true);

        return $now + $threshold > $this->start_time + (float) $max_execution_time;
    }
public function isTimeNearlyUp ( float $ threshold = self :: TIME_UP_THRESHOLD ) : bool { $ max_execution_time = ( int ) ini_get ( 'max_execution_time' ) ; // If there's no time limit, then we can't run out of time. if ( $ max_execution_time === 0 ) { return false ; } $ now = microtime ( true ) ; return $ now + $ threshold > $ this -> start_time + ( float ) $ max_execution_time ; }
Some long-running scripts need to know when to stop.

@param float $threshold

@return bool
Some long - running scripts need to know when to stop .