Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| AddressProcessProductLocationService | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| processProductLocation | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Address\Services; |
| 4 | |
| 5 | use App\Models\Address\Address; |
| 6 | use App\Models\Item\Item; |
| 7 | use Illuminate\Support\Collection; |
| 8 | |
| 9 | class AddressProcessProductLocationService |
| 10 | { |
| 11 | public function processProductLocation(Address $address): array |
| 12 | { |
| 13 | $products = []; |
| 14 | $storages = []; |
| 15 | if ($address->items->isNotEmpty()) { |
| 16 | $products = $address->items->filter(fn($item) => $item->product != null); |
| 17 | $storages = $address->items->filter(fn($item) => $item->storage != null); |
| 18 | } |
| 19 | |
| 20 | $productionOrders = new Collection(); |
| 21 | $address->items->each(function (Item $item) use (&$productionOrders) { |
| 22 | if (isset($item->integration->parameters['production_order'])) { |
| 23 | $productionOrders->push($item->integration->parameters['production_order']); |
| 24 | } |
| 25 | }); |
| 26 | |
| 27 | return [$products, $storages, $productionOrders]; |
| 28 | } |
| 29 | } |