NavigationCollection::addToCollection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Obblm\Core\Twig\Parts;
4
5
class NavigationCollection implements NavigationElementInterface
6
{
7
    protected $collection = [];
8
    protected $name = null;
9
    protected $icon = null;
10
11
    public function __construct($name = null, $icon = null, array $collection = [])
12
    {
13
        $this->collection = $collection;
14
        $this->name = $name;
15
        $this->icon = $icon;
16
    }
17
18
    public function getName(): ?string
19
    {
20
        return $this->name;
21
    }
22
23
    public function getIcon(): ?string
24
    {
25
        return $this->icon;
26
    }
27
28
    public function getCollection(): array
29
    {
30
        return $this->collection;
31
    }
32
33
    public function addToCollection(NavigationElementInterface $item): self
34
    {
35
        $this->collection[] = $item;
36
        return $this;
37
    }
38
39
    public function __toArray(): array
40
    {
41
        return (array) $this->collection;
42
    }
43
}
44