Completed
Push — master ( 8c3bdd...8107a8 )
by Mikołaj
13s
created

BlockFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createWithType() 0 8 1
A createNew() 0 7 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