Passed
Push — develop ( 53a66f...07e04a )
by Daniel
05:35
created

FeatureColumnsFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 10
ccs 8
cts 8
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Factory\Entity\Component\Feature\Columns;
4
5
use Silverback\ApiComponentBundle\Entity\Component\Feature\Columns\FeatureColumns;
6
use Silverback\ApiComponentBundle\Entity\Content\AbstractContent;
7
use Silverback\ApiComponentBundle\Factory\Entity\Component\AbstractComponentFactory;
8
9
class FeatureColumnsFactory extends AbstractComponentFactory
10
{
11
    /**
12
     * @inheritdoc
13
     */
14 1
    public function create(?array $ops = null): FeatureColumns
15
    {
16 1
        $component = new FeatureColumns();
17 1
        $this->init($component, $ops);
18 1
        $component->setTitle($this->ops['title']);
19 1
        if ($this->ops['columns']) {
20 1
            $component->setColumns($this->ops['columns']);
21
        }
22 1
        $this->validate($component);
23 1
        return $component;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29 2
    public static function defaultOps(): array
30
    {
31 2
        return array_merge(
32 2
            parent::defaultOps(),
33
            [
34 2
                'columns' => null,
35
                'title' => null
36
            ]
37
        );
38
    }
39
}
40