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

Page   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 49
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getComponent() 0 4 1
A hasComponent() 0 4 1
A setIcon() 0 6 1
A getTitle() 0 8 2
A getUrl() 0 8 2
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