Conditions | 9 |
Paths | 192 |
Total Lines | 67 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
138 | protected function setUserPreferences(): void |
||
139 | { |
||
140 | $this->userdata->categoryexclusions = User::getCategoryExclusionById(Auth::id()); |
||
141 | |||
142 | // Change the theme to user's selected theme if they selected one, else use the admin one. |
||
143 | if ((int) Settings::settingValue('site.main.userselstyle') === 1) { |
||
144 | $this->theme = $this->userdata->style ?? 'None'; |
||
145 | if ($this->theme === 'None') { |
||
146 | $this->theme = Settings::settingValue('site.main.style'); |
||
147 | } |
||
148 | } else { |
||
149 | $this->theme = Settings::settingValue('site.main.style'); |
||
150 | } |
||
151 | |||
152 | // Update last login every 15 mins. |
||
153 | if (now()->subHours(3) > $this->userdata->lastlogin) { |
||
154 | event(new UserLoggedIn($this->userdata)); |
||
155 | } |
||
156 | |||
157 | $this->smarty->assign('userdata', $this->userdata); |
||
158 | $this->smarty->assign('loggedin', 'true'); |
||
159 | |||
160 | if ($this->userdata->hasRole('Admin')) { |
||
161 | $this->smarty->assign('isadmin', 'true'); |
||
162 | } |
||
163 | |||
164 | if ($this->userdata->hasRole('Moderator')) { |
||
165 | $this->smarty->assign('ismod', 'true'); |
||
166 | } |
||
167 | |||
168 | // Tell Smarty which directories to use for templates |
||
169 | $this->smarty->setTemplateDir([ |
||
170 | 'user' => config('ytake-laravel-smarty.template_path').DIRECTORY_SEPARATOR.$this->theme, |
||
171 | 'shared' => config('ytake-laravel-smarty.template_path').'/shared', |
||
172 | 'default' => config('ytake-laravel-smarty.template_path').'/Gentele', |
||
173 | ]); |
||
174 | |||
175 | $role = User::ROLE_USER; |
||
176 | if (! empty($this->userdata)) { |
||
177 | $role = $this->userdata->roles_id; |
||
178 | } |
||
179 | |||
180 | $content = new Contents(); |
||
181 | $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role)); |
||
182 | $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role)); |
||
183 | if ($this->userdata !== null) { |
||
184 | $this->smarty->assign('recentforumpostslist', Forumpost::getPosts(Settings::settingValue('..showrecentforumposts'))); |
||
185 | } |
||
186 | |||
187 | $parentcatlist = Category::getForMenu($this->userdata->categoryexclusions); |
||
188 | |||
189 | $this->smarty->assign('parentcatlist', $parentcatlist); |
||
190 | $this->smarty->assign('catClass', Category::class); |
||
191 | |||
192 | if (\request()->has('t')) { |
||
193 | $this->smarty->assign('header_menu_cat', \request()->input('t')); |
||
194 | } else { |
||
195 | $this->smarty->assign('header_menu_cat', ''); |
||
196 | } |
||
197 | $header_menu = $this->smarty->fetch('headermenu.tpl'); |
||
198 | $this->smarty->assign('header_menu', $header_menu); |
||
199 | $notification = $this->smarty->fetch('notification.tpl'); |
||
200 | $this->smarty->assign('notification', $notification); |
||
201 | $sidebar = $this->smarty->fetch('sidebar.tpl'); |
||
202 | $this->smarty->assign('sidebar', $sidebar); |
||
203 | $footer = $this->smarty->fetch('footer.tpl'); |
||
204 | $this->smarty->assign('footer', $footer); |
||
205 | } |
||
262 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths