Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Date | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| localize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| parse | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Value; |
| 6 | |
| 7 | use DateTimeImmutable; |
| 8 | use IntlDateFormatter; |
| 9 | use Override; |
| 10 | |
| 11 | class Date extends DateTime |
| 12 | { |
| 13 | public const FORMAT = 'Y-m-d'; |
| 14 | |
| 15 | #[Override] |
| 16 | public function __toString(): string |
| 17 | { |
| 18 | return $this->format(static::FORMAT); |
| 19 | } |
| 20 | |
| 21 | #[Override] |
| 22 | public function localize( |
| 23 | int $dateFormat = IntlDateFormatter::MEDIUM, |
| 24 | int $timeFormat = IntlDateFormatter::NONE, |
| 25 | ): string { |
| 26 | return parent::localize($dateFormat, $timeFormat); |
| 27 | } |
| 28 | |
| 29 | #[Override] |
| 30 | protected function parse(string $value): ?DateTimeImmutable |
| 31 | { |
| 32 | return $this->parseFormat($value, static::FORMAT); |
| 33 | } |
| 34 | } |