| Total Complexity | 11 |
| Total Lines | 54 |
| 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 | * |
||
| 22 | * @param DateTimeInterface|string $value |
||
| 23 | */ |
||
| 24 | 11 | public function __construct($value = '') |
|
| 30 | 11 | } |
|
| 31 | |||
| 32 | 6 | public function __toString(): string |
|
| 33 | { |
||
| 34 | 6 | return $this->datetimeObject === null |
|
| 35 | 3 | ? parent::__toString() |
|
| 36 | 6 | : $this->datetimeObject->format(DateTimeInterface::RFC7231); |
|
| 37 | } |
||
| 38 | |||
| 39 | final public static function createHeader(): DateHeader |
||
| 40 | { |
||
| 41 | return new DateHeader(static::class); |
||
| 42 | } |
||
| 43 | |||
| 44 | 7 | final public function getDatetimeValue(): ?DateTimeImmutable |
|
| 45 | { |
||
| 46 | 7 | return $this->datetimeObject; |
|
| 47 | } |
||
| 48 | |||
| 49 | 1 | final public function withValueFromDatetime(DateTimeInterface $date): self |
|
| 50 | { |
||
| 51 | 1 | return $this->withValue($date->format(DateTimeInterface::RFC7231)); |
|
| 52 | } |
||
| 53 | |||
| 54 | 11 | final protected function setValue(string $value): void |
|
| 67 | 11 | } |
|
| 68 | } |
||
| 69 |