Completed
Push — master ( 8253ba...a023d2 )
by Daniel
16:49 queued 05:23
created

HeroFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 1
A defaultOps() 0 8 1
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Factory\Fixtures\Component;
4
5
use Silverback\ApiComponentBundle\Entity\Component\Hero\Hero;
6
use Silverback\ApiComponentBundle\Entity\Content\AbstractContent;
7
8
/**
9
 * @author Daniel West <[email protected]>
10
 */
11
final class HeroFactory extends AbstractComponentFactory
12
{
13
    /**
14
     * @inheritdoc
15
     */
16 2
    public function create(?array $ops = null, ?AbstractContent $owner = null): Hero
17
    {
18 2
        $component = new Hero();
19 2
        $this->init($component, $ops);
20 1
        $component->setTitle($this->ops['title']);
21 1
        $component->setSubtitle($this->ops['subtitle']);
22 1
        $component->setTabs($this->ops['tabs']);
23 1
        $this->validate($component);
24 1
        return $component;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 2
    public static function defaultOps(): array
31
    {
32 2
        return array_merge(
33 2
            parent::defaultOps(),
34
            [
35 2
                'title' => 'Untitled',
36
                'subtitle' => null,
37
                'tabs' => null
38
            ]
39
        );
40
    }
41
}
42