Completed
Push — master ( ea0a23...156714 )
by Joachim
12s queued 11s
created

BrandImageFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createNew() 0 6 1
A createForBrand() 0 7 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBrandPlugin\Factory;
6
7
use Loevgaard\SyliusBrandPlugin\Model\BrandImageInterface;
8
use Loevgaard\SyliusBrandPlugin\Model\BrandInterface;
9
use Sylius\Component\Resource\Factory\FactoryInterface;
10
11
class BrandImageFactory implements BrandImageFactoryInterface
12
{
13
    /**
14
     * @var FactoryInterface
15
     */
16
    private $factory;
17
18
    public function __construct(FactoryInterface $factory)
19
    {
20
        $this->factory = $factory;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function createNew(): BrandImageInterface
27
    {
28
        /** @var BrandImageInterface $brandImage */
29
        $brandImage = $this->factory->createNew();
30
31
        return $brandImage;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function createForBrand(BrandInterface $brand): BrandImageInterface
38
    {
39
        /** @var BrandImageInterface $brandImage */
40
        $brandImage = $this->createNew();
41
        $brandImage->setBrand($brand);
42
43
        return $brandImage;
44
    }
45
}
46