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
Pull Request — bs4 (#1113)
by
unknown
05:45
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
    public function setIcon($icon)
37
    {
38
        $this->icon = $icon;
39
40
        return $this;
41
    }
42
43
    /**
44
     * Set Alias Id.
45
     */
46
    public function setAliasId()
47
    {
48
        $url = parse_url($this->getUrl(), PHP_URL_PATH);
49
        if ($url) {
50
            $this->aliasId = md5($url);
51
        }
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getAliasId()
58
    {
59
        return $this->aliasId;
60
    }
61
62
    /**
63
     * @return ModelConfigurationInterface
64
     */
65
    public function getModelConfiguration()
66
    {
67
        if (! $this->hasModel()) {
68
            return;
69
        }
70
71
        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

71
        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...
72
    }
73
74
    /**
75
     * @return bool
76
     */
77
    public function hasModel()
78
    {
79
        return ! is_null($this->model) && class_exists($this->model);
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getId()
86
    {
87
        if (is_null($this->id) && $this->hasModel()) {
0 ignored issues
show
introduced by
The condition is_null($this->id) is always false.
Loading history...
88
            return $this->model;
89
        }
90
91
        return parent::getId();
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getTitle()
98
    {
99
        if (is_null($this->title) && $this->hasModel()) {
0 ignored issues
show
introduced by
The condition is_null($this->title) is always false.
Loading history...
100
            return $this->getModelConfiguration()->getTitle();
101
        }
102
103
        return parent::getTitle();
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getUrl()
110
    {
111
        if (is_null($this->url) && $this->hasModel()) {
0 ignored issues
show
introduced by
The condition is_null($this->url) is always false.
Loading history...
112
            return $this->getModelConfiguration()->getDisplayUrl();
113
        }
114
115
        return parent::getUrl();
116
    }
117
118
    /**
119
     * @return \Closure
120
     */
121
    public function getAccessLogic()
122
    {
123
        if (! is_callable($this->accessLogic)) {
124
            if ($this->hasModel()) {
125
                return function () {
126
                    return $this->getModelConfiguration()->isDisplayable();
127
                };
128
            }
129
        }
130
131
        return parent::getAccessLogic();
132
    }
133
134
    /**
135
     * @param string|null $view
136
     *
137
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
138
     */
139
    public function render($view = null)
140
    {
141
        if ($this->hasChild() && ! $this->hasClassProperty($class = config('navigation.class.has_child', 'treeview'))) {
142
            $this->setHtmlAttribute('class', $class);
143
        }
144
145
        $data = $this->toArray();
146
147
        if (! is_null($view)) {
148
            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...
149
        }
150
151
        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

151
        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...
152
    }
153
154
    /**
155
     * @param string $model
156
     *
157
     * @return $this
158
     */
159
    protected function setModel($model)
160
    {
161
        $this->model = $model;
162
163
        return $this;
164
    }
165
}
166