CartItemsProductProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getItemsProducts() 0 12 2
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace Pyz\Yves\CartPage\Plugin\Provider;
11
12
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToProductStorageClientInterface;
13
14
class CartItemsProductProvider implements CartItemsProductProviderInterface
15
{
16
    protected CartPageToProductStorageClientInterface $productStorageClient;
17
18
    public function __construct(CartPageToProductStorageClientInterface $productStorageClient)
19
    {
20
        $this->productStorageClient = $productStorageClient;
21
    }
22
23
    /**
24
     * @param array<\Generated\Shared\Transfer\ItemTransfer> $cartItems
25
     * @param string $locale
26
     *
27
     * @return array<\Generated\Shared\Transfer\ProductViewTransfer>
28
     */
29
    public function getItemsProducts(array $cartItems, string $locale): array
30
    {
31
        $productBySku = [];
32
33
        foreach ($cartItems as $item) {
34
            $productBySku[$item->getSku()] = $this->productStorageClient->findProductAbstractViewTransfer(
35
                $item->getIdProductAbstract(),
36
                $locale,
37
            );
38
        }
39
40
        return $productBySku;
41
    }
42
}
43