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