DocumentFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace Lakion\CmsPlugin\Factory;
4
5
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
6
use Sylius\Component\Resource\Factory\FactoryInterface;
7
8 View Code Duplication
final class DocumentFactory 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...
9
{
10
    /**
11
     * @var FactoryInterface
12
     */
13
    private $decoratedFactory;
14
15
    /**
16
     * @var DocumentManagerInterface
17
     */
18
    private $documentManager;
19
20
    /**
21
     * @var string
22
     */
23
    private $parentPath;
24
25
    /**
26
     * @param FactoryInterface $decoratedFactory
27
     * @param DocumentManagerInterface $documentManager
28
     * @param string $parentPath
29
     */
30
    public function __construct(FactoryInterface $decoratedFactory, DocumentManagerInterface $documentManager, $parentPath)
31
    {
32
        $this->decoratedFactory = $decoratedFactory;
33
        $this->documentManager = $documentManager;
34
        $this->parentPath = $parentPath;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function createNew()
41
    {
42
        $document = $this->decoratedFactory->createNew();
43
        $document->setParentDocument($this->documentManager->find(null, $this->parentPath));
44
45
        return $document;
46
    }
47
}
48