src/Clock.php
static function override($now): void
    {
        if ($now instanceof \DateTimeInterface) {
            $now = $now->getTimestamp() + ($now->format('u') / 1e6); // extract timestamp with microseconds
        } elseif (!is_int($now) && !is_float($now)) {
            throw new \InvalidArgumentException(sprintf(
                'Expected int, float or an instance of DateTimeInterface, but got %s',
                is_object($now) ? get_class($now) : gettype($now)
            ));
        }

        self::$now = $now;
    }
static function override($now): void
    {
        if ($now instanceof \DateTimeInterface) {
            $now = $now->getTimestamp() + ($now->format('u') / 1e6); // extract timestamp with microseconds
        } elseif (!is_int($now) && !is_float($now)) {
            throw new \InvalidArgumentException(sprintf(
                'Expected int, float or an instance of DateTimeInterface, but got %s',
                is_object($now) ? get_class($now) : gettype($now)
            ));
        }

        self::$now = $now;
    }
static function override ( $ now ) : void { if ( $ now instanceof \ DateTimeInterface ) { $ now = $ now -> getTimestamp ( ) + ( $ now -> format ( 'u' ) / 1e6 ) ; // extract timestamp with microseconds } elseif ( ! is_int ( $ now ) && ! is_float ( $ now ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected int, float or an instance of DateTimeInterface, but got %s' , is_object ( $ now ) ? get_class ( $ now ) : gettype ( $ now ) ) ) ; } self :: $ now = $ now ; }
Override the current time

- this change only affects methods of this class
- this method is intended to be used only for testing purposes
- the new time can include microseconds

@see Clock::resume()

@param \DateTimeInterface|int|float $now UNIX timestamp or \DateTimeInterface instance
@throws \InvalidArgumentException if $now does not have a valid type
Override the current time