Total Complexity | 4 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | final class Before |
||
19 | { |
||
20 | /** @var \DateTimeInterface */ |
||
21 | private $dateTime; |
||
22 | |||
23 | private function __construct(\DateTimeInterface $dateTime) |
||
24 | { |
||
25 | $this->dateTime = $dateTime; |
||
26 | } |
||
27 | |||
28 | public function __toString() |
||
29 | { |
||
30 | return $this->dateTime->format('Y-m-d\TH:i'); |
||
31 | } |
||
32 | |||
33 | public static function fromString(string $dateTime): self |
||
34 | { |
||
35 | $format = 'Y-m-d\TH:i'; |
||
36 | Assertion::date($dateTime, $format); |
||
37 | $dateTime = \DateTimeImmutable::createFromFormat($format, $dateTime); |
||
38 | |||
39 | return new self($dateTime); |
||
|
|||
40 | } |
||
41 | |||
42 | public static function fromDateTime(\DateTime $dateTime): self |
||
45 | } |
||
46 | } |
||
47 |