@@ -20,11 +20,9 @@ |
||
| 20 | 20 | public function compare($aBoxA, $aBoxB) { |
| 21 | 21 | if ($aBoxB->getInnerVolume() > $aBoxA->getInnerVolume()) { |
| 22 | 22 | return 1; |
| 23 | - } |
|
| 24 | - else if ($aBoxB->getInnerVolume() < $aBoxA->getInnerVolume()) { |
|
| 23 | + } else if ($aBoxB->getInnerVolume() < $aBoxA->getInnerVolume()) { |
|
| 25 | 24 | return -1; |
| 26 | - } |
|
| 27 | - else { |
|
| 25 | + } else { |
|
| 28 | 26 | return 0; |
| 29 | 27 | } |
| 30 | 28 | } |
@@ -60,14 +60,12 @@ discard block |
||
| 60 | 60 | public function setItems($aItems) { |
| 61 | 61 | if ($aItems instanceof ItemList) { |
| 62 | 62 | $this->items = clone $aItems; |
| 63 | - } |
|
| 64 | - else if (is_array($aItems)) { |
|
| 63 | + } else if (is_array($aItems)) { |
|
| 65 | 64 | $this->items = new ItemList(); |
| 66 | 65 | foreach ($aItems as $item) { |
| 67 | 66 | $this->items->insert($item); |
| 68 | 67 | } |
| 69 | - } |
|
| 70 | - else { |
|
| 68 | + } else { |
|
| 71 | 69 | throw new \RuntimeException('Not a valid list of items'); |
| 72 | 70 | } |
| 73 | 71 | } |
@@ -183,11 +181,9 @@ discard block |
||
| 183 | 181 | $boxWeight = $packedBox->getWeight(); |
| 184 | 182 | if ($boxWeight > $targetWeight) { |
| 185 | 183 | $overWeightBoxes[] = $packedBox; |
| 186 | - } |
|
| 187 | - else if ($boxWeight < $targetWeight) { |
|
| 184 | + } else if ($boxWeight < $targetWeight) { |
|
| 188 | 185 | $underWeightBoxes[] = $packedBox; |
| 189 | - } |
|
| 190 | - else { |
|
| 186 | + } else { |
|
| 191 | 187 | $packedBoxes->insert($packedBox); //target weight, so we'll keep these |
| 192 | 188 | } |
| 193 | 189 | } |
@@ -302,8 +298,7 @@ discard block |
||
| 302 | 298 | $remainingLength -= $itemLength; |
| 303 | 299 | $layerLength += $itemLength; |
| 304 | 300 | $layerWidth = max($itemWidth, $layerWidth); |
| 305 | - } |
|
| 306 | - else { |
|
| 301 | + } else { |
|
| 307 | 302 | $this->logger->log(LogLevel::DEBUG, "fits (better) rotated"); |
| 308 | 303 | $remainingLength -= $itemWidth; |
| 309 | 304 | $layerLength += $itemWidth; |
@@ -322,13 +317,11 @@ discard block |
||
| 322 | 317 | $remainingWeight -= $potentialStackItem->getWeight(); |
| 323 | 318 | $maxStackDepth -= $potentialStackItem->getDepth(); |
| 324 | 319 | $packedItems->insert($aItems->extract()); |
| 325 | - } |
|
| 326 | - else { |
|
| 320 | + } else { |
|
| 327 | 321 | break; |
| 328 | 322 | } |
| 329 | 323 | } |
| 330 | - } |
|
| 331 | - else { |
|
| 324 | + } else { |
|
| 332 | 325 | if ($remainingWidth >= min($itemWidth, $itemLength) && $layerDepth > 0 && $layerWidth > 0 && $layerLength > 0) { |
| 333 | 326 | $this->logger->log(LogLevel::DEBUG, "No more fit in lengthwise, resetting for new row"); |
| 334 | 327 | $remainingLength += $layerLength; |
@@ -20,11 +20,9 @@ |
||
| 20 | 20 | public function compare($aItemA, $aItemB) { |
| 21 | 21 | if ($aItemA->getVolume() > $aItemB->getVolume()) { |
| 22 | 22 | return 1; |
| 23 | - } |
|
| 24 | - else if ($aItemA->getVolume() < $aItemB->getVolume()) { |
|
| 23 | + } else if ($aItemA->getVolume() < $aItemB->getVolume()) { |
|
| 25 | 24 | return -1; |
| 26 | - } |
|
| 27 | - else { |
|
| 25 | + } else { |
|
| 28 | 26 | return 0; |
| 29 | 27 | } |
| 30 | 28 | } |