| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | trait DateTrait |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Example: "2014-10-18 23:03:21" |
||
| 27 | * |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | public $date; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @internal |
||
| 34 | * @param string $date |
||
| 35 | */ |
||
| 36 | public function setDate(string $date): void |
||
| 37 | { |
||
| 38 | $this->date = $date; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @internal |
||
| 43 | * @param string|null $format |
||
| 44 | * @return string |
||
| 45 | */ |
||
| 46 | public function getDate(string $format = null): string |
||
| 47 | { |
||
| 48 | return $format |
||
| 49 | ? $this->getDateTime()->format($format) |
||
| 50 | : $this->date; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return DateTime |
||
| 55 | */ |
||
| 56 | public function getDateTime(): DateTime |
||
| 65 | } |
||
| 66 | } |