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.

Issues (389)

Branch: master

src/Templates/Template.php (4 issues)

1
<?php
2
3
namespace SleepingOwl\Admin\Templates;
4
5
use Illuminate\Contracts\Foundation\Application;
6
use Illuminate\View\View;
7
use SleepingOwl\Admin\Contracts\AdminInterface;
8
use SleepingOwl\Admin\Contracts\Navigation\NavigationInterface;
9
use SleepingOwl\Admin\Contracts\Template\MetaInterface;
10
use SleepingOwl\Admin\Contracts\Template\TemplateInterface;
11
12
abstract class Template implements TemplateInterface
13
{
14
    /**
15
     * @var Application
16
     */
17
    protected $app;
18
19
    /**
20
     * @var MetaInterface
21
     */
22
    protected $meta;
23
24
    /**
25
     * @var NavigationInterface
26
     */
27
    protected $navigation;
28
29
    /**
30
     * @var Breadcrumbs
31
     */
32
    protected $breadcrumbs;
33
34
    /**
35
     * @var AdminInterface
36
     */
37
    protected $admin;
38
39
    /**
40
     * TemplateDefault constructor.
41
     *
42
     * @param Application $application
43
     * @param AdminInterface $admin
44
     * @param MetaInterface $meta
45
     * @param NavigationInterface $navigation
46
     * @param Breadcrumbs $breadcrumbs
47
     */
48 285
    public function __construct(
49
        Application $application,
50
        AdminInterface $admin,
51
        MetaInterface $meta,
52
        NavigationInterface $navigation,
53
        Breadcrumbs $breadcrumbs
54
    ) {
55 285
        $this->app = $application;
56 285
        $this->meta = $meta;
57 285
        $this->navigation = $navigation;
58 285
        $this->breadcrumbs = $breadcrumbs;
59 285
        $this->admin = $admin;
60 285
    }
61
62
    /**
63
     * Название с указанием версии.
64
     *
65
     * @return string
66
     */
67
    public function longName()
68
    {
69
        return $this->name().' v.'.$this->version();
70
    }
71
72
    /**
73
     * @return Breadcrumbs
74
     */
75
    public function breadcrumbs()
76
    {
77
        return $this->breadcrumbs;
78
    }
79
80
    /**
81
     * @return MetaInterface
82
     */
83 285
    public function meta()
84
    {
85 285
        return $this->meta;
86
    }
87
88
    /**
89
     * @return NavigationInterface
90
     */
91
    public function navigation()
92
    {
93
        return $this->navigation;
94
    }
95
96
    /**
97
     * Генерация относительно пути до asset файлов для текущей темы.
98
     *
99
     * @param string $path относительный путь до файла, например `js/app.js`
100
     *
101
     * @return string
102
     */
103 285
    public function assetPath($path = null)
104
    {
105 285
        return ! is_null($path) ? $this->assetDir().'/'.ltrim($path, '/') : $this->assetDir();
106
    }
107
108
    /**
109
     * @return string
110
     */
111 2
    public function getTitle()
112
    {
113 2
        return config('sleeping_owl.title');
114
    }
115
116
    /**
117
     * @param string $title
118
     * @param string $separator
119
     *
120
     * @return string
121
     */
122 1
    public function makeTitle($title, $separator = ' | ')
123
    {
124 1
        if (empty($title)) {
125 1
            return $this->getTitle();
126
        }
127
128 1
        return strip_tags($title)."{$separator}".$this->getTitle();
129
    }
130
131
    /**
132
     * @param string $view
133
     *
134
     * @return string
135
     */
136 285
    public function getViewPath($view)
137
    {
138 285
        if ($view instanceof View) {
0 ignored issues
show
$view is never a sub-type of Illuminate\View\View.
Loading history...
139 1
            return $view->getPath();
140
        }
141
142 285
        if (strpos($view, '::') !== false) {
143
            return $view;
144
        }
145
146 285
        return $this->getViewNamespace().'.'.$view;
147
    }
148
149
    /**
150
     * @param string|View $view
151
     * @param array $data
152
     * @param array $mergeData
153
     *
154
     * @return \Illuminate\Contracts\View\Factory|View
155
     */
156 1
    public function view($view, array $data = [], $mergeData = [])
157
    {
158 1
        $data['template'] = $this;
159
160 1
        if ($view instanceof View) {
161 1
            return $view->with($data);
162
        }
163
164 1
        return view($this->getViewPath($view), $data, $mergeData);
165
    }
166
167
    /**
168
     * @param string $key
169
     *
170
     * @return string
171
     * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\InvalidBreadcrumbException
172
     * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\UnnamedRouteException
173
     * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\ViewNotSetException
174
     */
175
    public function renderBreadcrumbs($key)
176
    {
177
        if (config('sleeping_owl.breadcrumbs')) {
178
            config()->set('breadcrumbs.view', $this->getViewPath('_partials.breadcrumbs'));
179
180
            return $this->breadcrumbs()->renderIfExists($key);
181
        }
182
    }
183
184
    /**
185
     * @return string
186
     */
187
    public function renderNavigation()
188
    {
189
        return $this->navigation()->render(
190
            $this->getViewPath('_partials.navigation.navigation')
0 ignored issues
show
The call to Illuminate\Contracts\Support\Renderable::render() has too many arguments starting with $this->getViewPath('_par...navigation.navigation'). ( Ignorable by Annotation )

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

190
        return $this->navigation()->/** @scrutinizer ignore-call */ render(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
191
        );
192
    }
193
194
    /**
195
     * Регистрация стандартны�
196
     * глобальны�
197
     * Javascript перменны�
198
     * .
199
     */
200
    protected function setGlobalVariables()
201
    {
202
        $globalVars = $this->admin->scriptVariables();
0 ignored issues
show
The method scriptVariables() does not exist on SleepingOwl\Admin\Contracts\AdminInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to SleepingOwl\Admin\Contracts\AdminInterface. ( Ignorable by Annotation )

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

202
        /** @scrutinizer ignore-call */ 
203
        $globalVars = $this->admin->scriptVariables();
Loading history...
203
204
        foreach ($globalVars as $var => $value) {
205
            $this->meta->putGlobalVar($var, $value);
0 ignored issues
show
The method putGlobalVar() does not exist on SleepingOwl\Admin\Contracts\Template\MetaInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to SleepingOwl\Admin\Contracts\Template\MetaInterface. ( Ignorable by Annotation )

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

205
            $this->meta->/** @scrutinizer ignore-call */ 
206
                         putGlobalVar($var, $value);
Loading history...
206
        }
207
    }
208
209
    /**
210
     * @param string $title
211
     *
212
     * @return string
213
     */
214
    public function renderMeta($title)
215
    {
216
        $this->setGlobalVariables();
217
218
        return $this->meta()
219
            ->setTitle($this->makeTitle($title))
220
            ->addMeta(['charset' => 'utf-8'], 'meta::charset')
221
            ->addMeta(['content' => csrf_token(), 'name' => 'csrf-token'])
222
            ->addMeta(['content' => 'width=device-width, initial-scale=1', 'name' => 'viewport'])
223
            ->addMeta(['content' => 'IE=edge', 'http-equiv' => 'X-UA-Compatible'])
224
            ->render();
225
    }
226
227
    /**
228
     * Render func.
229
     * @return array
230
     */
231
    public function toArray()
232
    {
233
        return [
234
            'asset_dir' => $this->assetDir(),
235
            'view_namespace' => $this->getViewNamespace(),
236
            'name' => $this->name(),
237
            'version' => $this->version(),
238
            'homepage' => $this->homepage(),
239
        ];
240
    }
241
}
242