Skip to content

Commit

Permalink
More PHP5.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jul 14, 2019
1 parent b4081b4 commit 9245ee4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/OrientatedItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ public function getBestOrientation(
// if not an easy either/or, do a partial lookahead
$additionalPackedA = $this->calculateAdditionalItemsPackedWithThisOrientation($a, $nextItems, $widthLeft, $lengthLeft, $depthLeft, $rowLength);
$additionalPackedB = $this->calculateAdditionalItemsPackedWithThisOrientation($b, $nextItems, $widthLeft, $lengthLeft, $depthLeft, $rowLength);
if ($additionalPackedA !== $additionalPackedB) {
return $additionalPackedB - $additionalPackedA;
if ($additionalPackedA > $additionalPackedB) {
return -1;
}
if ($additionalPackedA < $additionalPackedB) {
return 1;
}
if ($additionalPackedA === 0) {
return PHP_MAJOR_VERSION > 5 ? -1 : 1;
}
}
// otherwise prefer leaving minimum possible gap, or the greatest footprint
Expand Down

0 comments on commit 9245ee4

Please sign in to comment.