| Conditions | 7 |
| Paths | 12 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 43 | public function pack(): PackedBoxList |
||
| 44 | { |
||
| 45 | foreach ($this->items as $item) { |
||
| 46 | foreach ($this->boxes as $box) { |
||
| 47 | if ($item->getWeight() <= ($box->getMaxWeight() - $box->getEmptyWeight()) && (new OrientatedItemFactory($box))->hasPossibleOrientationsInEmptyBox($item)) { |
||
| 48 | continue 2; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | $this->unpackedItems->insert($item); |
||
| 52 | $this->items->remove($item); |
||
| 53 | } |
||
| 54 | |||
| 55 | while (true) { |
||
| 56 | try { |
||
| 57 | return parent::pack(); |
||
| 58 | } catch (NoBoxesAvailableException $e) { |
||
| 59 | $this->unpackedItems->insert($e->getItem()); |
||
| 60 | $this->items->remove($e->getItem()); |
||
| 61 | } |
||
| 65 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: