@@ -8,7 +8,6 @@ |
||
8 | 8 | |
9 | 9 | use Psr\Log\LoggerAwareInterface; |
10 | 10 | use Psr\Log\LoggerAwareTrait; |
11 | -use Psr\Log\LoggerInterface; |
|
12 | 11 | use Psr\Log\NullLogger; |
13 | 12 | |
14 | 13 | /** |
@@ -205,7 +205,7 @@ |
||
205 | 205 | * Used when we've packed a tall item, and have just put a shorter one next to it |
206 | 206 | * |
207 | 207 | * @param PackedItemList $packedItems |
208 | - * @param ?PackedItem $prevItem |
|
208 | + * @param null|PackedItem $prevItem |
|
209 | 209 | * @param int $maxWidth |
210 | 210 | * @param int $maxLength |
211 | 211 | * @param int $maxDepth |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | use Psr\Log\LoggerAwareInterface; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | int $maxWidth, |
193 | 193 | int $maxLength, |
194 | 194 | int $maxDepth |
195 | - ): ?OrientatedItem { |
|
195 | + ) : ?OrientatedItem { |
|
196 | 196 | $this->logger->debug( |
197 | 197 | "evaluating item {$itemToPack->getDescription()} for fit", |
198 | 198 | [ |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | int $x, |
235 | 235 | int $y, |
236 | 236 | int $z |
237 | - ): void { |
|
237 | + ) : void { |
|
238 | 238 | while (count($this->items) > 0 && $this->checkNonDimensionalConstraints($this->items->top(), $packedItems)) { |
239 | 239 | $stackedItem = $this->getOrientationForItem( |
240 | 240 | $this->items->top(), |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $items = iterator_to_array($packedItems, false); |
329 | 329 | $packedItems = new PackedItemList(); |
330 | 330 | /** @var PackedItem $item */ |
331 | - foreach($items as $item) { |
|
331 | + foreach ($items as $item) { |
|
332 | 332 | $packedItems->insert( |
333 | 333 | new PackedItem( |
334 | 334 | $item->getItem(), |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | /** |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | use Psr\Log\LoggerAwareInterface; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | int $widthLeft, |
44 | 44 | int $lengthLeft, |
45 | 45 | int $depthLeft |
46 | - ): ?OrientatedItem { |
|
46 | + ) : ?OrientatedItem { |
|
47 | 47 | |
48 | 48 | $possibleOrientations = $this->getPossibleOrientations($item, $prevItem, $widthLeft, $lengthLeft, $depthLeft); |
49 | 49 | $usableOrientations = $this->getUsableOrientations($possibleOrientations, $box, $item, $isLastItem); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | int $widthLeft, |
82 | 82 | int $lengthLeft, |
83 | 83 | int $depthLeft |
84 | - ): array { |
|
84 | + ) : array { |
|
85 | 85 | |
86 | 86 | $orientations = []; |
87 | 87 | |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getPossibleOrientationsInEmptyBox(Item $item, Box $box): array |
119 | 119 | { |
120 | - $cacheKey = $item->getWidth() . |
|
121 | - '|' . |
|
122 | - $item->getLength() . |
|
123 | - '|' . |
|
124 | - $item->getDepth() . |
|
125 | - '|' . |
|
126 | - ($item->getKeepFlat() ? '2D' : '3D') . |
|
127 | - '|' . |
|
128 | - $box->getInnerWidth() . |
|
129 | - '|' . |
|
130 | - $box->getInnerLength() . |
|
131 | - '|' . |
|
120 | + $cacheKey = $item->getWidth(). |
|
121 | + '|'. |
|
122 | + $item->getLength(). |
|
123 | + '|'. |
|
124 | + $item->getDepth(). |
|
125 | + '|'. |
|
126 | + ($item->getKeepFlat() ? '2D' : '3D'). |
|
127 | + '|'. |
|
128 | + $box->getInnerWidth(). |
|
129 | + '|'. |
|
130 | + $box->getInnerLength(). |
|
131 | + '|'. |
|
132 | 132 | $box->getInnerDepth(); |
133 | 133 | |
134 | 134 | if (isset(static::$emptyBoxCache[$cacheKey])) { |
@@ -7,9 +7,9 @@ |
||
7 | 7 | declare(strict_types=1); |
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | +use Psr\Log\LogLevel; |
|
10 | 11 | use Psr\Log\LoggerAwareInterface; |
11 | 12 | use Psr\Log\LoggerAwareTrait; |
12 | -use Psr\Log\LogLevel; |
|
13 | 13 | use Psr\Log\NullLogger; |
14 | 14 | |
15 | 15 | /** |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | use Psr\Log\LoggerAwareInterface; |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | |
69 | 69 | do { //Keep moving items from most overweight box to most underweight box |
70 | 70 | $tryRepack = false; |
71 | - $this->logger->log(LogLevel::DEBUG, 'boxes under/over target: ' . count($underWeightBoxes) . '/' . count($overWeightBoxes)); |
|
71 | + $this->logger->log(LogLevel::DEBUG, 'boxes under/over target: '.count($underWeightBoxes).'/'.count($overWeightBoxes)); |
|
72 | 72 | |
73 | 73 | usort($overWeightBoxes, [$this, 'sortMoreSpaceFirst']); |
74 | 74 | usort($underWeightBoxes, [$this, 'sortMoreSpaceFirst']); |
75 | 75 | |
76 | 76 | foreach ($underWeightBoxes as $u => $underWeightBox) { |
77 | - $this->logger->log(LogLevel::DEBUG, 'Underweight Box ' . $u); |
|
77 | + $this->logger->log(LogLevel::DEBUG, 'Underweight Box '.$u); |
|
78 | 78 | foreach ($overWeightBoxes as $o => $overWeightBox) { |
79 | - $this->logger->log(LogLevel::DEBUG, 'Overweight Box ' . $o); |
|
79 | + $this->logger->log(LogLevel::DEBUG, 'Overweight Box '.$o); |
|
80 | 80 | $overWeightBoxItems = $overWeightBox->getItems()->asItemArray(); |
81 | 81 | |
82 | 82 | //For each item in the heavier box, try and move it to the lighter one |
83 | 83 | /** @var Item $overWeightBoxItem */ |
84 | 84 | foreach ($overWeightBoxItems as $oi => $overWeightBoxItem) { |
85 | - $this->logger->log(LogLevel::DEBUG, 'Overweight Item ' . $oi); |
|
85 | + $this->logger->log(LogLevel::DEBUG, 'Overweight Item '.$oi); |
|
86 | 86 | if ($underWeightBox->getWeight() + $overWeightBoxItem->getWeight() > $targetWeight) { |
87 | 87 | $this->logger->log(LogLevel::DEBUG, 'Skipping item for hindering weight distribution'); |
88 | 88 | continue; //skip if moving this item would hinder rather than help weight distribution |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | /** |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | /** |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | /** |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | /** |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * @package BoxPacker |
5 | 5 | * @author Doug Wright |
6 | 6 | */ |
7 | -declare(strict_types=1); |
|
7 | +declare(strict_types = 1); |
|
8 | 8 | namespace DVDoug\BoxPacker; |
9 | 9 | |
10 | 10 | /** |