| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3.576 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 59 | 15 | public static function compare($boxA, $boxB): int |
|
| 60 | { |
||
| 61 | 15 | $boxAVolume = $boxA->getInnerWidth() * $boxA->getInnerLength() * $boxA->getInnerDepth(); |
|
| 62 | 15 | $boxBVolume = $boxB->getInnerWidth() * $boxB->getInnerLength() * $boxB->getInnerDepth(); |
|
| 63 | |||
| 64 | 15 | $volumeDecider = $boxAVolume <=> $boxBVolume; // try smallest box first |
|
| 65 | |||
| 66 | 15 | if ($volumeDecider !== 0) { |
|
| 67 | 15 | return $volumeDecider; |
|
| 68 | } |
||
| 69 | |||
| 70 | $emptyWeightDecider = $boxA->getEmptyWeight() <=> $boxB->getEmptyWeight(); // with smallest empty weight |
||
| 71 | if ($emptyWeightDecider !== 0) { |
||
| 72 | return $emptyWeightDecider; |
||
| 73 | } |
||
| 74 | |||
| 75 | // maximum weight capacity as fallback decider |
||
| 76 | return ($boxA->getMaxWeight() - $boxA->getEmptyWeight()) <=> ($boxB->getMaxWeight() - $boxB->getEmptyWeight()); |
||
| 77 | } |
||
| 79 |