Completed
Pull Request — master (#95)
by
unknown
01:14
created

BlockFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file was created by the developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusCmsPlugin\Factory;
14
15
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
16
use Sylius\Component\Resource\Factory\FactoryInterface;
17
18
/**
19
 * @author Patryk Drapik <[email protected]>
20
 */
21
final class BlockFactory implements BlockFactoryInterface
22
{
23
    /**
24
     * @var FactoryInterface
25
     */
26
    private $factory;
27
28
    /**
29
     * @param FactoryInterface $factory
30
     */
31
    public function __construct(FactoryInterface $factory)
32
    {
33
        $this->factory = $factory;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function createWithType(string $type): BlockInterface
40
    {
41
        /** @var BlockInterface $block */
42
        $block = $this->factory->createNew();
43
        $block->setType($type);
44
45
        return $block;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function createNew(): BlockInterface
52
    {
53
        /** @var BlockInterface $block */
54
        $block = $this->factory->createNew();
55
56
        return $block;
57
    }
58
}
59