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

BrandImageFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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