| Conditions | 5 |
| Paths | 4 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 2 | public function getCurrent() |
|
| 35 | { |
||
| 36 | 2 | if (1 > $this->count()) { |
|
| 37 | 1 | return; |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | $current = null; |
|
| 41 | |||
| 42 | 1 | foreach ($this->all() as $schedule) { |
|
| 43 | 1 | if (empty($current) || $schedule->getDateInit() > $current->getDateInit()) { |
|
| 44 | 1 | $current = $schedule; |
|
| 45 | } |
||
| 46 | } |
||
| 47 | 1 | $convert = function ($int) { |
|
| 48 | 1 | return date('d-m-Y', ($int / 1000)); |
|
| 49 | 1 | }; |
|
| 50 | $current->setDateInit($convert($schedule->getDateInit())); |
||
|
|
|||
| 51 | $current->setDateEnd($convert($schedule->getDateEnd())); |
||
| 52 | |||
| 53 | return $current; |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
It seems like you are relying on a variable being defined by an iteration: