MockClock
in package
implements
ClockInterface
FinalYes
A clock that always returns the same date, suitable for testing time-sensitive logic.
Consider using ClockSensitiveTrait in your test cases instead of using this class directly.
Tags
Table of Contents
Interfaces
Properties
Methods
- __construct() : mixed
- modify() : void
- now() : DatePoint
- Returns the current time as a DateTimeImmutable Object
- sleep() : void
- withTimeZone() : static
Properties
$now
private
DatePoint
$now
Methods
__construct()
public
__construct([DateTimeImmutable|string $now = 'now' ][, DateTimeZone|string|null $timezone = null ]) : mixed
Parameters
- $now : DateTimeImmutable|string = 'now'
- $timezone : DateTimeZone|string|null = null
Tags
modify()
public
modify(string $modifier) : void
Parameters
- $modifier : string
Tags
now()
Returns the current time as a DateTimeImmutable Object
public
now() : DatePoint
Return values
DatePointsleep()
public
sleep(float|int $seconds) : void
Parameters
- $seconds : float|int
withTimeZone()
public
withTimeZone(DateTimeZone|string $timezone) : static
Parameters
- $timezone : DateTimeZone|string