Completed
Pull Request — master (#290)
by
unknown
36:49 queued 34:03
created

DetailedProductViewFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A create() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\SyliusShopApiPlugin\Factory;
6
7
use Sylius\Component\Core\Model\ChannelInterface;
8
use Sylius\Component\Core\Model\ProductInterface;
9
use Sylius\SyliusShopApiPlugin\Generator\ProductBreadcrumbGeneratorInterface;
10
use Sylius\SyliusShopApiPlugin\View\ProductView;
11
12
final class DetailedProductViewFactory implements ProductViewFactoryInterface
13
{
14
    /** @var ProductViewFactoryInterface */
15
    private $productViewFactory;
16
17
    /** @var ProductBreadcrumbGeneratorInterface */
18
    private $breadcrumbGenerator;
19
20
    public function __construct(
21
        ProductViewFactoryInterface $productViewFactory,
22
        ProductBreadcrumbGeneratorInterface $breadcrumbGenerator
23
    ) {
24
        $this->productViewFactory = $productViewFactory;
25
        $this->breadcrumbGenerator = $breadcrumbGenerator;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function create(ProductInterface $product, ChannelInterface $channel, string $locale): ProductView
32
    {
33
        $productView = $this->productViewFactory->create($product, $channel, $locale);
34
        $productView->breadcrumb = $this->breadcrumbGenerator->generate($product, $locale);
35
36
        return $productView;
37
    }
38
}
39