| Conditions | 4 |
| Paths | 8 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 5 | public function convert($input) |
|
| 15 | { |
||
| 16 | 5 | if (!$input) { |
|
| 17 | 1 | return; |
|
| 18 | } |
||
| 19 | |||
| 20 | // dd.mm.yyyy, dd-mm-yyyy |
||
| 21 | try { |
||
| 22 | 4 | if (preg_match('/^([0-9]{1,2})[\.-]?([0-9]{1,2})[\.-]?([0-9]{2,4})$/', $input, $matches)) { |
|
| 23 | 3 | $date = new \DateTime($matches[3].'-'.$matches[2].'-'.$matches[1]); |
|
| 24 | } else { |
||
| 25 | 1 | $date = new \DateTime($input); |
|
| 26 | } |
||
| 27 | |||
| 28 | 3 | return $this->formatOutput($date); |
|
| 29 | 1 | } catch (\Exception $e) { |
|
| 30 | 1 | return $input; |
|
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 39 |