| @@ 93-103 (lines=11) @@ | ||
| 90 | * |
|
| 91 | * @return int |
|
| 92 | */ |
|
| 93 | private function compare(PackedBox $boxA, PackedBox $boxB): int |
|
| 94 | { |
|
| 95 | $choice = $boxB->getItems()->count() <=> $boxA->getItems()->count(); |
|
| 96 | if ($choice === 0) { |
|
| 97 | $choice = $boxB->getInnerVolume() <=> $boxA->getInnerVolume(); |
|
| 98 | } |
|
| 99 | if ($choice === 0) { |
|
| 100 | $choice = $boxA->getWeight() <=> $boxB->getWeight(); |
|
| 101 | } |
|
| 102 | return $choice; |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Calculate the average (mean) weight of the boxes |
|
| @@ 215-225 (lines=11) @@ | ||
| 212 | * |
|
| 213 | * @return int |
|
| 214 | */ |
|
| 215 | private static function compare(PackedBox $boxA, PackedBox $boxB): int |
|
| 216 | { |
|
| 217 | $choice = $boxB->getItems()->count() <=> $boxA->getItems()->count(); |
|
| 218 | if ($choice === 0) { |
|
| 219 | $choice = $boxA->getInnerVolume() <=> $boxB->getInnerVolume(); |
|
| 220 | } |
|
| 221 | if ($choice === 0) { |
|
| 222 | $choice = $boxA->getWeight() <=> $boxB->getWeight(); |
|
| 223 | } |
|
| 224 | return $choice; |
|
| 225 | } |
|
| 226 | } |
|
| 227 | ||