src/Traits/ClockTrait.php
static function atTime($now, callable $callback)
    {
        // store time if already overridden
        if (Clock::isOverridden()) {
            $previousOverride = Clock::microtime();
        } else {
            $previousOverride = null;
        }

        try {
            // override time
            Clock::override($now);

            // invoke callback
            return $callback();
        } finally {
            // restore previous state
            if ($previousOverride === null) {
                // no previous override - resume
                Clock::resume();
            } else {
                // restore previous override
                Clock::override($previousOverride);
            }
        }
    }
static function atTime($now, callable $callback)
    {
        // store time if already overridden
        if (Clock::isOverridden()) {
            $previousOverride = Clock::microtime();
        } else {
            $previousOverride = null;
        }

        try {
            // override time
            Clock::override($now);

            // invoke callback
            return $callback();
        } finally {
            // restore previous state
            if ($previousOverride === null) {
                // no previous override - resume
                Clock::resume();
            } else {
                // restore previous override
                Clock::override($previousOverride);
            }
        }
    }
static function atTime ( $ now , callable $ callback ) { // store time if already overridden if ( Clock :: isOverridden ( ) ) { $ previousOverride = Clock :: microtime ( ) ; } else { $ previousOverride = null ; } try { // override time Clock :: override ( $ now ) ; // invoke callback return $ callback ( ) ; } finally { // restore previous state if ( $ previousOverride === null ) { // no previous override - resume Clock :: resume ( ) ; } else { // restore previous override Clock :: override ( $ previousOverride ) ; } } }
Override current time for the duration of the callback

@param \DateTimeInterface|int|float $now
@param callable $callback callback to invoke
@return mixed return value of the callback
Override current time for the duration of the callback