| Conditions | 7 |
| Paths | 7 |
| Total Lines | 30 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 7.0957 |
| 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 | // try smallest box first |
||
| 33 | 9 | if ($boxBVolume > $boxAVolume) { |
|
| 34 | 8 | return 1; |
|
| 35 | } |
||
| 36 | 4 | if ($boxAVolume > $boxBVolume) { |
|
| 37 | 1 | return -1; |
|
| 38 | } |
||
| 39 | |||
| 40 | // smallest empty weight |
||
| 41 | 4 | if ($boxB->getEmptyWeight() > $boxA->getEmptyWeight()) { |
|
| 42 | return 1; |
||
| 43 | } |
||
| 44 | 4 | if ($boxA->getEmptyWeight() > $boxB->getEmptyWeight()) { |
|
| 45 | return -1; |
||
| 46 | } |
||
| 47 | |||
| 48 | // maximum weight capacity as fallback decider |
||
| 49 | 4 | if ($boxB->getMaxWeight() > $boxA->getMaxWeight()) { |
|
| 50 | 1 | return 1; |
|
| 51 | } |
||
| 52 | 4 | if ($boxA->getMaxWeight() > $boxB->getMaxWeight()) { |
|
| 53 | 1 | return -1; |
|
| 54 | } |
||
| 55 | |||
| 56 | 3 | return 0; |
|
| 57 | } |
||
| 59 |