| Total Complexity | 5 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class DateTime extends NamedColumn |
||
| 10 | { |
||
| 11 | use DateFormat; |
||
| 12 | /** |
||
| 13 | * Datetime format. |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $format; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Datetime timezone. |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $timezone; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $view = 'column.datetime'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param Model $model |
||
| 31 | * |
||
| 32 | * @return $this |
||
| 33 | */ |
||
| 34 | public function setModel(Model $model) |
||
| 35 | { |
||
| 36 | parent::setModel($model); |
||
| 37 | $this->setHtmlAttribute('data-value', $this->getModelValue()); |
||
| 38 | |||
| 39 | return $this; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | public function toArray() |
||
| 46 | { |
||
| 47 | $value = $this->getModelValue(); |
||
| 48 | |||
| 49 | return parent::toArray() + [ |
||
| 50 | 'value' => $this->getFormatedDate($value), |
||
| 51 | 'originalValue' => $value, |
||
| 52 | ]; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param string $date |
||
| 57 | * |
||
| 58 | * @return null|string |
||
| 59 | */ |
||
| 60 | protected function getFormatedDate($date) |
||
| 71 | } |
||
| 72 | } |
||
| 73 |