| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3.009 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 9 | public function compare($boxA, $boxB) |
|
| 28 | { |
||
| 29 | 9 | $boxAVolume = $boxA->getInnerWidth() * $boxA->getInnerLength() * $boxA->getInnerDepth(); |
|
| 30 | 9 | $boxBVolume = $boxB->getInnerWidth() * $boxB->getInnerLength() * $boxB->getInnerDepth(); |
|
| 31 | |||
| 32 | 9 | $volumeDecider = $boxBVolume - $boxAVolume; // try smallest box first |
|
| 33 | 9 | $emptyWeightDecider = $boxA->getEmptyWeight() - $boxB->getEmptyWeight(); // with smallest empty weight |
|
| 34 | |||
| 35 | 9 | if ($volumeDecider !== 0) { |
|
| 36 | 8 | return $volumeDecider; |
|
| 37 | } |
||
| 38 | 4 | if ($emptyWeightDecider !== 0) { |
|
| 39 | return $emptyWeightDecider; |
||
| 40 | } |
||
| 41 | |||
| 42 | // maximum weight capacity as fallback decider |
||
| 43 | 4 | return ($boxB->getMaxWeight() - $boxB->getEmptyWeight()) - ($boxA->getMaxWeight() - $boxA->getEmptyWeight()); |
|
| 44 | } |
||
| 46 |