Conditions | 3 |
Paths | 3 |
Total Lines | 28 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
35 | public function map() |
||
36 | { |
||
37 | foreach ($this->attributes as $attribute) { |
||
38 | $value = $this->owner->{$attribute}; |
||
39 | |||
40 | $date = null; |
||
41 | preg_replace_callback_array( |
||
42 | [ |
||
43 | '/^\d{4}\-\d{2}\-\d{2}$/' => function ($match) use (&$date) { |
||
44 | $date = Carbon::createFromFormat('Y-m-d', $match[0]); |
||
45 | }, |
||
46 | '/^\d{2}\.\d{2}\.\d{4}$/' => function ($match) use (&$date) { |
||
47 | $date = Carbon::createFromFormat('d.m.Y', $match[0]); |
||
48 | }, |
||
49 | '/^\d+$/' => function ($match) use (&$date) { |
||
50 | $date = Carbon::createFromTimestamp($match[0]); |
||
51 | } |
||
52 | ], |
||
53 | $value |
||
54 | ); |
||
55 | |||
56 | if (!$date instanceof Carbon) { |
||
57 | continue; |
||
58 | } |
||
59 | |||
60 | $this->owner->{$attribute} = $date->format($this->format); |
||
61 | } |
||
62 | } |
||
63 | } |