| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public function getSlice($offset, $length) |
||
| 30 | { |
||
| 31 | $items = array(); |
||
| 32 | $resources = parent::getSlice($offset, $length); |
||
| 33 | |||
| 34 | try { |
||
| 35 | foreach ($resources as $itemData) { |
||
|
|
|||
| 36 | $items[] = new Item($itemData); |
||
| 37 | } |
||
| 38 | } catch (Exception $e) { |
||
| 39 | throw new InvalidDataException('Could not convert resources to items.', $e->getCode(), $e); |
||
| 40 | } |
||
| 41 | |||
| 42 | return $items; |
||
| 43 | } |
||
| 44 | } |
||
| 45 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.