UnmovingClock   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A standingStillAt() 0 3 1
A now() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Clock;
4
5
use DateTimeInterface;
6
7
/**
8
 * UnmovingClock. This clock has stopped ticking.
9
 * It stands still at a given point in time. Like the one at grandma's.
10
 * Bit sad for the clock, but very nice for testing.
11
 *
12
 * @author Stratadox
13
 */
14
final class UnmovingClock implements Clock
15
{
16
    private $when;
17
18
    private function __construct(DateTimeInterface $when)
19
    {
20
        $this->when = $when;
21
    }
22
23
    public static function standingStillAt(DateTimeInterface $dateTime): Clock
24
    {
25
        return new self($dateTime);
26
    }
27
28
    public function now(): DateTimeInterface
29
    {
30
        return $this->when;
31
    }
32
}
33