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

ArticleFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

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