Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
AddressProcessProductLocationService
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 processProductLocation
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace Domain\Address\Services;
4
5use App\Models\Address\Address;
6use App\Models\Item\Item;
7use Illuminate\Support\Collection;
8
9class 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}