Completed
Push — master ( c02284...70d821 )
by wen
14:01
created

Page::setIcon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Sco\Admin\Navigation;
4
5
6
class Page extends \KodiComponents\Navigation\Page
7
{
8
    /**
9
     * @var null|\Sco\Admin\Contracts\ComponentInterface
10
     */
11
    protected $component;
12
13
    public function __construct($component = null)
14
    {
15
        parent::__construct();
16
17
        $this->component = $component;
18
    }
19
20
    public function getComponent()
21
    {
22
        return $this->component;
23
    }
24
25
    public function hasComponent()
26
    {
27
        return !is_null($this->getComponent());
28
    }
29
30
    public function setIcon($icon)
31
    {
32
        $this->icon = $icon;
33
34
        return $this;
35
    }
36
37
    public function getTitle()
38
    {
39
        if ($this->hasComponent()) {
40
            return $this->getComponent()->getTitle();
41
        }
42
43
        return parent::getTitle();
44
    }
45
46
    public function getUrl()
47
    {
48
        if ($this->hasComponent()) {
49
            return $this->getComponent()->getViewUrl();
50
        }
51
52
        return parent::getUrl();
53
    }
54
}
55