Conditions | 4 |
Paths | 8 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | 5 | public function convert($input) |
|
15 | { |
||
16 | 5 | if (!$input) { |
|
17 | 1 | return null; |
|
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 | 3 | } 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 | |||
40 |