Total Complexity | 4 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class DateTimeZoneFactory implements DateTimeZoneFactoryInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var class-string<\DateTimeZone> |
||
|
|||
13 | */ |
||
14 | private string $dateTimeZoneClassName; |
||
15 | |||
16 | /** |
||
17 | * @throws DateTimeZoneFactoryException |
||
18 | */ |
||
19 | public function __construct(string $dateTimeZoneClassName = null) |
||
20 | { |
||
21 | $dateTimeZoneClassName ??= \DateTimeZone::class; |
||
22 | if (!is_a($dateTimeZoneClassName, \DateTimeZone::class, true)) { |
||
23 | throw new DateTimeZoneFactoryException( |
||
24 | sprintf( |
||
25 | 'The \'dateTimeZoneClassName\' parameter must be a class name that implements \'%s\'', |
||
26 | \DateTimeZone::class |
||
27 | ) |
||
28 | ); |
||
29 | } |
||
30 | $this->dateTimeZoneClassName = $dateTimeZoneClassName; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @throws DateTimeZoneFactoryException |
||
35 | */ |
||
36 | public function createDateTimeZone(string $spec): \DateTimeZone |
||
46 | ); |
||
47 | } |
||
50 |