started = microtime( true ); $this->seconds = $seconds ?? self::derive_seconds(); } /** * Ob das Budget aufgebraucht ist. * * @return bool */ public function exhausted(): bool { return $this->remaining() <= 0; } /** * Verbleibende Sekunden. * * @return float */ public function remaining(): float { return $this->seconds - ( microtime( true ) - $this->started ); } /** * Die Laenge des Budgets fuer diesen Host. * * @return float */ private static function derive_seconds(): float { $limit = (int) ini_get( 'max_execution_time' ); if ( $limit <= 0 ) { return self::MAX_SECONDS; } return (float) max( 5, min( self::MAX_SECONDS, $limit - self::SAFETY_SECONDS ) ); } }