MutableClock
in package
implements
ClockInterface
Mutable clock class
A clock whose time can be explicitly set and advanced, for deterministic testing of TTL/expiration behavior without real sleep() calls.
Tags
Table of Contents
Interfaces
- ClockInterface
- Clock interface
Properties
- $time : int
- Current time as a Unix timestamp
Methods
- __construct() : mixed
- Constructor
- advance() : MutableClock
- Advance the current time by a number of seconds
- now() : int
- Get the current time as a Unix timestamp
- setTime() : MutableClock
- Set the current time
Properties
$time
Current time as a Unix timestamp
protected
int
$time
Methods
__construct()
Constructor
public
__construct([int|null $time = null ]) : mixed
Instantiate the mutable clock object
Parameters
- $time : int|null = null
advance()
Advance the current time by a number of seconds
public
advance(int $seconds) : MutableClock
Parameters
- $seconds : int
Return values
MutableClocknow()
Get the current time as a Unix timestamp
public
now() : int
Return values
intsetTime()
Set the current time
public
setTime(int $time) : MutableClock
Parameters
- $time : int