Total Complexity | 8 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 90% |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class TestClock implements Clock |
||
13 | { |
||
14 | /** |
||
15 | * @private |
||
16 | */ |
||
17 | const FORMAT_OF_TIME = 'Y-m-d H:i:s.uO'; |
||
18 | |||
19 | /** |
||
20 | * @var DateTimeImmutable |
||
21 | */ |
||
22 | private $time; |
||
23 | |||
24 | /** |
||
25 | * @var DateTimeZone |
||
26 | */ |
||
27 | private $timeZone; |
||
28 | |||
29 | 24 | public function __construct(DateTimeZone $timeZone = null) |
|
33 | 24 | } |
|
34 | |||
35 | 24 | public function tick(): void |
|
38 | 24 | } |
|
39 | |||
40 | 2 | public function fixate(string $input): void |
|
41 | { |
||
42 | 2 | $preciseTime = sprintf('%s.000000', $input); |
|
43 | 2 | $dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s.u', $preciseTime, $this->timeZone); |
|
44 | |||
45 | 2 | if ( ! $dateTime instanceof DateTimeImmutable) { |
|
46 | 1 | throw new InvalidArgumentException("Invalid input for date/time fixation provided: {$input}"); |
|
47 | } |
||
48 | |||
49 | 1 | $this->time = $dateTime; |
|
50 | 1 | } |
|
51 | |||
52 | 8 | public function dateTime(): DateTimeImmutable |
|
55 | } |
||
56 | |||
57 | 5 | public function pointInTime(): PointInTime |
|
60 | } |
||
61 | |||
62 | public function timeZone(): DateTimeZone |
||
67 |