UnmovingClock::standingStillAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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