Completed
Push — develop ( 07cc15...4f6410 )
by Daniel
05:45
created

GalleryItemFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

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