diff --git a/src/OrientatedItemFactory.php b/src/OrientatedItemFactory.php index 1fe4f595..4e19d3d6 100644 --- a/src/OrientatedItemFactory.php +++ b/src/OrientatedItemFactory.php @@ -87,7 +87,11 @@ public function getBestOrientation( $orientationAMinGap = min($orientationAWidthLeft, $orientationALengthLeft); $orientationBMinGap = min($orientationBWidthLeft, $orientationBLengthLeft); - if ($orientationAMinGap === 0 && ($orientationBMinGap !== 0 || PHP_MAJOR_VERSION > 5)) { // prefer A if it leaves no gap + if ($orientationAMinGap === 0 && $orientationBMinGap === 0) { + return $a->getDepth() - $b->getDepth(); + } + + if ($orientationAMinGap === 0 && $orientationBMinGap !== 0) { // prefer A if it leaves no gap return -1; } if ($orientationBMinGap === 0) { // prefer B if it leaves no gap