Passed
Push — develop ( 83a19a...5dcd0c )
by Daniel
05:43
created

AbstractComponentFactory::getIgnoreOps()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Factory\Entity\Content\Component;
4
5
use Silverback\ApiComponentBundle\Entity\Content\Component\AbstractComponent;
6
use Silverback\ApiComponentBundle\Entity\Content\Component\ComponentLocation;
7
use Silverback\ApiComponentBundle\Factory\Entity\AbstractFactory;
8
9
abstract class AbstractComponentFactory extends AbstractFactory
10
{
11
    /**
12
     * @param AbstractComponent $component
13
     * @param array|null $ops
14
     */
15 22
    protected function init($component, ?array $ops = null): void
16
    {
17 22
        parent::init($component, $ops);
18
        if (
19 22
            $this->ops['parentContent'] &&
20 22
            !$component->isContentComponent($this->ops['parentContent'])
21
        ) {
22
            $location = new ComponentLocation($this->ops['parentContent'], $component);
23
            $component->addLocation($location);
24
            $this->manager->persist($location);
25
        }
26 22
    }
27
28 18
    protected static function getIgnoreOps(): array
29
    {
30
        return [
31 18
            'parentContent'
32
        ];
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 43
    protected static function defaultOps(): array
39
    {
40
        return [
41 43
            'className' => null,
42
            'parentComponent' => null,
43
            'parentContent' => null
44
        ];
45
    }
46
}
47