DateTimeFactory::now()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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