Passed
Pull Request — master (#84)
by Frank
10:26
created

SystemClock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 2
A timeZone() 0 3 1
A now() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing\Time;
6
7
use DateTimeImmutable;
8
use DateTimeZone;
9
10
class SystemClock implements Clock
11
{
12
    /**
13
     * @var DateTimeZone
14
     */
15
    private $timeZone;
16
17
    public function __construct(DateTimeZone $timeZone = null)
18 24
    {
19
        $this->timeZone = $timeZone ?: new DateTimeZone('UTC');
20 24
    }
21 24
22
    public function now(): DateTimeImmutable
23 14
    {
24
        return new DateTimeImmutable('now', $this->timeZone);
25 14
    }
26
27
    public function timeZone(): DateTimeZone
28 13
    {
29
        return $this->timeZone;
30 13
    }
31
}
32