From 9245ee4f010fc6b005fa5886f3489ebb144b5d1d Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sun, 14 Jul 2019 19:39:18 +0100 Subject: [PATCH] More PHP5.x compatibility --- src/OrientatedItemFactory.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/OrientatedItemFactory.php b/src/OrientatedItemFactory.php index d679202d..53394272 100644 --- a/src/OrientatedItemFactory.php +++ b/src/OrientatedItemFactory.php @@ -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