Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| AddressProcessProductWarehouseLocationService | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| processProductLocation | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
3 | |||
| 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 AddressProcessProductWarehouseLocationService |
| 10 | { |
| 11 | public function processProductLocation(Address $address): array |
| 12 | { |
| 13 | $products = []; |
| 14 | if ($address->items->isNotEmpty()) { |
| 15 | $products = $address->items->filter(fn($item) => $item->product != null); |
| 16 | } |
| 17 | |
| 18 | $priorityValue = new Collection(); |
| 19 | $address->items->each(function (Item $item) use (&$priorityValue) { |
| 20 | if (isset($item->integration->parameters['priority_value'])) |
| 21 | { |
| 22 | $priorityValue->push($item->integration->parameters['priority_value']); |
| 23 | } |
| 24 | }); |
| 25 | |
| 26 | return [$products, $priorityValue]; |
| 27 | } |
| 28 | } |