| Total Complexity | 11 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 91.67% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 13 | class Date extends BaseHeaderValue |
||
| 14 | { |
||
| 15 | public const NAME = 'Date'; |
||
| 16 | |||
| 17 | private ?DateTimeImmutable $datetimeObject = null; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Date constructor. |
||
| 21 | * @param DateTimeInterface|string $value |
||
| 22 | */ |
||
| 23 | 11 | public function __construct($value = '') |
|
| 29 | 11 | } |
|
| 30 | |||
| 31 | 6 | public function __toString(): string |
|
| 32 | { |
||
| 33 | 6 | return $this->datetimeObject === null |
|
| 34 | 3 | ? parent::__toString() |
|
| 35 | 6 | : $this->datetimeObject->format(DateTimeInterface::RFC7231); |
|
| 36 | } |
||
| 37 | |||
| 38 | final public static function createHeader(): DateHeader |
||
| 39 | { |
||
| 40 | return new DateHeader(static::class); |
||
| 41 | } |
||
| 42 | |||
| 43 | 7 | final public function getDatetimeValue(): ?DateTimeImmutable |
|
| 44 | { |
||
| 45 | 7 | return $this->datetimeObject; |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | final public function withValueFromDatetime(DateTimeInterface $date): self |
|
| 49 | { |
||
| 50 | 1 | return $this->withValue($date->format(DateTimeInterface::RFC7231)); |
|
| 51 | } |
||
| 52 | |||
| 53 | 11 | final protected function setValue(string $value): void |
|
| 66 | 11 | } |
|
| 67 | } |
||
| 68 |