28 lines
382 B
PHP
28 lines
382 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
final class MutableClock implements Clock
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
private $time;
|
||
|
|
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
$this->time = 'now';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setTime($time)
|
||
|
|
{
|
||
|
|
$this->time = $time;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* {@inheritdoc}
|
||
|
|
*/
|
||
|
|
public function now()
|
||
|
|
{
|
||
|
|
return new \DateTimeImmutable($this->time);
|
||
|
|
}
|
||
|
|
}
|