Passed
Push — master ( 9a31c8...63c7d9 )
by Jon
02:01
created

Gallery::setItem()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 6
nc 5
nop 1
dl 0
loc 10
rs 8.8571
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($items)
22
    {
23
        if (is_array($items)) {
24
            foreach ($items as $item) {
25
                if ($item instanceof AbstractComponent) {
26
                    array_push($this->items, $item);
27
                }
28
            }
29
        } else if ($items instanceof AbstractComponent) {
30
            array_push($this->items, $items);
31
        }
32
    }
33
34
    private function getItems()
35
    {
36
        return $this->items;
37
    }
38
39
    protected function getComponent()
40
    {
41
        $component = new \stdClass();
42
        $component->role  = $this->getRole();
43
        $component->items = $this->getItems();
44
        return $component;
45
    }
46
}
47