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