| Conditions | 6 |
| Paths | 9 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | 6 | public function applyToNode(Node $node) |
|
| 21 | { |
||
| 22 | 6 | $instruction = $node->getInstruction($this); |
|
| 23 | |||
| 24 | 6 | if(!isset($instruction->date) && !isset($instruction->input)) { |
|
| 25 | 1 | return; |
|
| 26 | } |
||
| 27 | |||
| 28 | 5 | $format = 'Y-m-d'; |
|
| 29 | 5 | if (isset($instruction->format)) { |
|
| 30 | 5 | $format = $instruction->format; |
|
| 31 | 5 | } |
|
| 32 | |||
| 33 | 5 | $input = isset($instruction->input) ? $instruction->input : $instruction->date; |
|
| 34 | 5 | $date = new \DateTime($input); |
|
| 35 | 5 | if (isset($instruction->timezone)) { |
|
| 36 | 1 | $date = new \DateTime($input, new \DateTimeZone($instruction->timezone)); |
|
| 37 | 1 | } |
|
| 38 | |||
| 39 | 5 | $result = $date->format($format); |
|
| 40 | |||
| 41 | 5 | $node->setResult($result); |
|
| 42 | 5 | } |
|
| 43 | } |
||
| 44 |