Skip to content

Commit

Permalink
Explain logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jul 29, 2013
1 parent 660858b commit 9227a47
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Packer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,16 @@ public function pack() {
}
}

/*
* Check iteration was productive
*/
if ($packedBoxesIteration->isEmpty()) {
throw new \RuntimeException('Item ' . $unpackedItems->top()->getDescription() . ' is too large to fit into any box');
}

/*
* Find best box of iteration, and remove packed items from unpacked list
*/
$bestBox = $packedBoxesIteration->top();
for ($i = 0; $i < $bestBox->getItems()->count(); $i++) {
$unpackedItems->extract();
Expand Down

0 comments on commit 9227a47

Please sign in to comment.