| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 75 | 17 | public static function compare($boxA, $boxB): int |
|
| 76 | { |
||
| 77 | 17 | $boxAVolume = $boxA->getInnerWidth() * $boxA->getInnerLength() * $boxA->getInnerDepth(); |
|
| 78 | 17 | $boxBVolume = $boxB->getInnerWidth() * $boxB->getInnerLength() * $boxB->getInnerDepth(); |
|
| 79 | |||
| 80 | 17 | $volumeDecider = $boxAVolume <=> $boxBVolume; // try smallest box first |
|
| 81 | |||
| 82 | 17 | if ($volumeDecider !== 0) { |
|
| 83 | 13 | return $volumeDecider; |
|
| 84 | } |
||
| 85 | |||
| 86 | 4 | $emptyWeightDecider = $boxA->getEmptyWeight() <=> $boxB->getEmptyWeight(); // with smallest empty weight |
|
| 87 | 4 | if ($emptyWeightDecider !== 0) { |
|
| 88 | 4 | return $emptyWeightDecider; |
|
| 89 | } |
||
| 90 | |||
| 91 | // maximum weight capacity as fallback decider |
||
| 92 | 1 | return ($boxA->getMaxWeight() - $boxA->getEmptyWeight()) <=> ($boxB->getMaxWeight() - $boxB->getEmptyWeight()); |
|
| 93 | } |
||
| 95 |