DateTimeFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
c 0
b 0
f 0
dl 0
loc 15
ccs 0
cts 4
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A now() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Distribution\Internal;
6
7
/**
8
 * @internal DateTimeFactory is an internal library class, please do not use it in your code.
9
 * @psalm-internal Spiral\Distribution
10
 */
11
final class DateTimeFactory implements DateTimeFactoryInterface
12
{
13
    private const DEFAULT_TIMEZONE = 'UTC';
14
    private const DATE_NOW = 'now';
15
16
    private readonly \DateTimeZone $timezone;
17
18
    public function __construct(string $timezone = self::DEFAULT_TIMEZONE)
19
    {
20
        $this->timezone = new \DateTimeZone($timezone);
0 ignored issues
show
Bug introduced by
The property timezone is declared read-only in Spiral\Distribution\Internal\DateTimeFactory.
Loading history...
21
    }
22
23
    public function now(): \DateTimeImmutable
24
    {
25
        return new \DateTimeImmutable(self::DATE_NOW, $this->timezone);
26
    }
27
}
28