@@ 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 |
@@ 98-108 (lines=11) @@ | ||
95 | * |
|
96 | * @return int |
|
97 | */ |
|
98 | private function compare(PackedBox $boxA, PackedBox $boxB): int |
|
99 | { |
|
100 | $choice = $boxB->getItems()->count() <=> $boxA->getItems()->count(); |
|
101 | if ($choice === 0) { |
|
102 | $choice = $boxB->getInnerVolume() <=> $boxA->getInnerVolume(); |
|
103 | } |
|
104 | if ($choice === 0) { |
|
105 | $choice = $boxA->getWeight() <=> $boxB->getWeight(); |
|
106 | } |
|
107 | return $choice; |
|
108 | } |
|
109 | ||
110 | /** |
|
111 | * Calculate the average (mean) weight of the boxes |