Test Failed
Push — master ( a7f4b4...72df4e )
by Jesse
02:10
created

TImeZoneAwareMutableClock::now()   A

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 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Clock;
4
5
use DateTime;
6
use DateTimeInterface;
7
use DateTimeZone;
8
9
/**
10
 * TImeZoneAwareMutableClock. This clock is just like a regular mutable clock,
11
 * except that it knows in which time zone it operates.
12
 *
13
 * @author Stratadox
14
 */
15
final class TImeZoneAwareMutableClock implements Clock
16
{
17
    private $timeZone;
18
19
    public function __construct(DateTimeZone $timeZone)
20
    {
21
        $this->timeZone = $timeZone;
22
    }
23
24
    public static function in(DateTimeZone $timeZone): self
25
    {
26
        return new self($timeZone);
27
    }
28
29
    public function now(): DateTimeInterface
30
    {
31
        return new DateTime('now', $this->timeZone);
32
    }
33
}
34