| Total Complexity | 7 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class DateColumn extends DataColumn |
||
| 10 | { |
||
| 11 | protected $dateFormat = 'd.m.Y'; |
||
| 12 | |||
| 13 | public function getCellContent($entity) |
||
| 14 | { |
||
| 15 | $value = $this->getCellValue($entity); |
||
| 16 | if ($value instanceof DateTime) { |
||
| 17 | return $value->format($this->dateFormat); |
||
| 18 | } elseif (is_string($value) && !empty($this->dateFormat)) { |
||
| 19 | return date($this->dateFormat, strtotime($value)); |
||
| 20 | } |
||
| 21 | $value = (string)$value; |
||
| 22 | return empty($value) ? $this->emptyValue : $value; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | public function getDateFormat(): ?string |
||
| 29 | { |
||
| 30 | return $this->dateFormat; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param string $dateFormat |
||
| 35 | */ |
||
| 36 | protected function setDateFormat(?string $dateFormat): void |
||
| 39 | } |
||
| 40 | } |
||
| 41 |