| Total Complexity | 6 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | final class RoughDate implements \JsonSerializable |
||
| 20 | { |
||
| 21 | const DEFAULT_DATE_FORMAT = 'Y-m-d'; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | private $date; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $dateString |
||
| 30 | */ |
||
| 31 | private function __construct(string $dateString) |
||
| 32 | { |
||
| 33 | $this->date = $dateString; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param string $string |
||
| 38 | * |
||
| 39 | * @return RoughDate |
||
| 40 | */ |
||
| 41 | public static function fromString(string $string): RoughDate |
||
| 42 | { |
||
| 43 | $noramlizer = new StringDateNormalizer(); |
||
| 44 | |||
| 45 | return new RoughDate($noramlizer->normalize($string)); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param \DateTimeInterface $dateTime |
||
| 50 | * |
||
| 51 | * @return RoughDate |
||
| 52 | */ |
||
| 53 | public static function fromDateTime(\DateTimeInterface $dateTime): RoughDate |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function __toString(): string |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param string $format |
||
| 68 | * |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | public function format(string $format = self::DEFAULT_DATE_FORMAT): string |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | public function jsonSerialize(): string |
||
| 86 |