1 | <?php namespace rtens\domin\delivery\web\fields; |
||
8 | class DateIntervalField extends CliDateIntervalField implements WebField { |
||
9 | |||
10 | /** |
||
11 | * @param Parameter $parameter |
||
12 | * @param \DateInterval $value |
||
13 | * @return string |
||
14 | */ |
||
15 | public function render(Parameter $parameter, $value) { |
||
40 | |||
41 | /** |
||
42 | * @param Parameter $parameter |
||
43 | * @param string $serialized |
||
44 | * @return \DateInterval |
||
45 | */ |
||
46 | public function inflate(Parameter $parameter, $serialized) { |
||
47 | if (!$serialized) { |
||
48 | return $parameter->isRequired() ? new \DateInterval('P0D') : null; |
||
49 | } |
||
50 | |||
51 | $days = isset($serialized['d']) ? intval($serialized['d']) : 0; |
||
52 | $hours = isset($serialized['h']) ? intval($serialized['h']) : 0; |
||
53 | $minutes = isset($serialized['i']) ? intval($serialized['i']) : 0; |
||
54 | |||
55 | return new \DateInterval("P{$days}DT{$hours}H{$minutes}M"); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param Parameter $parameter |
||
60 | * @return array|\rtens\domin\delivery\web\Element[] |
||
61 | */ |
||
62 | public function headElements(Parameter $parameter) { |
||
65 | } |