Completed
Push — master ( 3182b0...115a8b )
by Arkadiusz
11s
created

StringBlockFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace Lakion\SyliusCmsBundle\Factory;
4
5
use Doctrine\Common\Persistence\ObjectManager;
6
use Lakion\SyliusCmsBundle\Document\StringBlock;
7
use Sylius\Component\Resource\Factory\FactoryInterface;
8
9 View Code Duplication
final class StringBlockFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @var FactoryInterface
13
     */
14
    private $decoratedFactory;
15
16
    /**
17
     * @var ObjectManager
18
     */
19
    private $documentManager;
20
21
    /**
22
     * @var string
23
     */
24
    private $stringBlockParentPath;
25
26
    /**
27
     * @param FactoryInterface $decoratedFactory
28
     * @param ObjectManager $documentManager
29
     * @param string $stringBlockParentPath
30
     */
31
    public function __construct(FactoryInterface $decoratedFactory, ObjectManager $documentManager, $stringBlockParentPath)
32
    {
33
        $this->decoratedFactory = $decoratedFactory;
34
        $this->documentManager = $documentManager;
35
        $this->stringBlockParentPath = $stringBlockParentPath;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function createNew()
42
    {
43
        /** @var StringBlock $stringBlock */
44
        $stringBlock = $this->decoratedFactory->createNew();
45
        $stringBlock->setParentDocument($this->documentManager->find(null, $this->stringBlockParentPath));
46
47
        return $stringBlock;
48
    }
49
}
50