GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — bs4 ( 482ba1...27b2c5 )
by Andrey
21:53 queued 16:41
created

Page::setIcon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SleepingOwl\Admin\Navigation;
4
5
use SleepingOwl\Admin\Contracts\Navigation\PageInterface;
6
use SleepingOwl\Admin\Contracts\ModelConfigurationInterface;
7
8
class Page extends \KodiComponents\Navigation\Page implements PageInterface
9
{
10
    /**
11
     * Menu item related model class.
12
     * @var string
13
     */
14
    protected $model;
15
16
    /**
17
     * Menu item by url id.
18
     * @var string
19
     */
20
    protected $aliasId;
21
22
    /**
23
     * @param string|null $modelClass
24
     */
25
    public function __construct($modelClass = null)
26
    {
27
        parent::__construct();
28
29
        $this->setModel($modelClass);
30
31
        if ($this->hasModel()) {
32
            $this->setIcon($this->getModelConfiguration()->getIcon());
33
        }
34
    }
35
36
    /**
37
     * Set Alias Id.
38
     */
39
    public function setAliasId()
40
    {
41
        $url = parse_url($this->getUrl(), PHP_URL_PATH);
42
        if ($url) {
43
            $this->aliasId = md5($url);
44
        }
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getAliasId()
51
    {
52
        return $this->aliasId;
53
    }
54
55
    /**
56
     * @return ModelConfigurationInterface
57
     */
58
    public function getModelConfiguration()
59
    {
60
        if (! $this->hasModel()) {
61
            return;
62
        }
63
64
        return app('sleeping_owl')->getModel($this->model);
0 ignored issues
show
Bug introduced by
The method getModel() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
        return app('sleeping_owl')->/** @scrutinizer ignore-call */ getModel($this->model);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
65
    }
66
67
    /**
68
     * @return bool
69
     */
70
    public function hasModel()
71
    {
72
        return ! is_null($this->model) && class_exists($this->model);
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getId()
79
    {
80
        if (is_null($this->id) && $this->hasModel()) {
0 ignored issues
show
introduced by
The condition is_null($this->id) is always false.
Loading history...
81
            return $this->model;
82
        }
83
84
        return parent::getId();
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function getTitle()
91
    {
92
        if (is_null($this->title) && $this->hasModel()) {
0 ignored issues
show
introduced by
The condition is_null($this->title) is always false.
Loading history...
93
            return $this->getModelConfiguration()->getTitle();
94
        }
95
96
        return parent::getTitle();
97
    }
98
99
    /**
100
     * @return string
101
     */
102
    public function getUrl()
103
    {
104
        if (is_null($this->url) && $this->hasModel()) {
0 ignored issues
show
introduced by
The condition is_null($this->url) is always false.
Loading history...
105
            return $this->getModelConfiguration()->getDisplayUrl();
106
        }
107
108
        return parent::getUrl();
109
    }
110
111
    /**
112
     * @return \Closure
113
     */
114
    public function getAccessLogic()
115
    {
116
        if (! is_callable($this->accessLogic)) {
117
            if ($this->hasModel()) {
118
                return function () {
119
                    return $this->getModelConfiguration()->isDisplayable();
120
                };
121
            }
122
        }
123
124
        return parent::getAccessLogic();
125
    }
126
127
    /**
128
     * @param string|null $view
129
     *
130
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
131
     */
132
    public function render($view = null)
133
    {
134
        if ($this->hasChild() && ! $this->hasClassProperty($class = config('navigation.class.has_child', 'treeview'))) {
135
            $this->setHtmlAttribute('class', $class);
136
        }
137
138
        $data = $this->toArray();
139
140
        if (! is_null($view)) {
141
            return view($view, $data)->render();
0 ignored issues
show
Bug Best Practice introduced by
The expression return view($view, $data)->render() returns the type array|string which is incompatible with the documented return type Illuminate\Contracts\Vie...ry|Illuminate\View\View.
Loading history...
142
        }
143
144
        return app('sleeping_owl.template')->view('_partials.navigation.page', $data)->render();
0 ignored issues
show
Bug introduced by
The method view() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

144
        return app('sleeping_owl.template')->/** @scrutinizer ignore-call */ view('_partials.navigation.page', $data)->render();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
145
    }
146
147
    /**
148
     * @param string $model
149
     *
150
     * @return $this
151
     */
152
    protected function setModel($model)
153
    {
154
        $this->model = $model;
155
156
        return $this;
157
    }
158
}
159