Passed
Push — master ( 04cf7a...5cb2ae )
by Jon
03:42
created

Gallery::setRole()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php namespace FlatPlan\Components;
2
3
use FlatPlan\Components\Image;
4
5
class Gallery extends AbstractComponent {
6
7
    protected $items = array();
8
9
    protected $roles = ['gallery', 'mosaic'];
10
11
    /**
12
     * @param string $role
13
     * @param string $bannerType
14
     * @return void
15
     */
16
    public function __construct($role)
17
    {
18
        $this->setRole($role);
19
    }
20
21
    public function setItem($item)
22
    {
23
        if ($item instanceof Image) {
24
            array_push($this->items, $item);
25
        } else {
26
            throw new \ErrorException('Invalid image component supplied.');
27
        }
28
    }
29
30
    private function getItems()
31
    {
32
        return $this->items;
33
    }
34
35
    protected function getComponent()
36
    {
37
        $component = new \stdClass();
38
        $component->role  = $this->getRole();
39
        $component->items = $this->getItems();
40
        return $component;
41
    }
42
}
43