4use Wikimedia\Assert\Assert;
17 private static ?
int $mockTime =
null;
24 private ?
int $referenceTime =
null;
29 'The Clock class requires 64-bit integers to support nanosecond timing'
37 $this->referenceTime ??= (int)( 1e9 * microtime( true ) ) - hrtime( true );
38 return self::$mockTime ?? ( $this->referenceTime + hrtime(
true ) );
48 public static function setMockTime( ?
int $epochNanos ): void {
49 Assert::precondition( defined(
'MW_PHPUNIT_TEST' ),
'This method should only be used in tests' );
50 self::$mockTime = $epochNanos;