ComparerProductFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A createForComparerAndProduct() 0 8 1
A createNew() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Locastic\SyliusComparerPlugin\Factory;
6
7
use Locastic\SyliusComparerPlugin\Entity\ComparerInterface;
8
use Locastic\SyliusComparerPlugin\Entity\ComparerProductInterface;
9
use Sylius\Component\Core\Model\ProductInterface;
10
use Sylius\Component\Resource\Factory\FactoryInterface;
11
12
class ComparerProductFactory implements ComparerProductFactoryInterface
13
{
14
    /** @var FactoryInterface */
15
    private $comparerProductFactory;
16
17
    public function __construct(FactoryInterface $comparerProductFactory)
18
    {
19
        $this->comparerProductFactory = $comparerProductFactory;
20
    }
21
22
    public function createNew(): ComparerProductInterface
23
    {
24
        /** @var ComparerProductInterface $comparerProduct */
25
        $comparerProduct = $this->comparerProductFactory->createNew();
26
27
        return $comparerProduct;
28
    }
29
30
    public function createForComparerAndProduct(ComparerInterface $comparer, ProductInterface $product): ComparerProductInterface
31
    {
32
        $comparerProduct = $this->createNew();
33
34
        $comparerProduct->setComparer($comparer);
35
        $comparerProduct->setProduct($product);
36
37
        return $comparerProduct;
38
    }
39
}
40