Conditions | 10 |
Paths | 24 |
Total Lines | 61 |
Code Lines | 35 |
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 |
||
15 | public function show(Request $request) |
||
16 | { |
||
17 | $this->setPreferences(); |
||
18 | $contents = new Contents; |
||
19 | |||
20 | $role = $this->userdata->role ?? 0; |
||
21 | |||
22 | /* The role column in the content table values are : |
||
23 | * 1 = logged in users |
||
24 | * 2 = admins |
||
25 | * |
||
26 | * The user role values are: |
||
27 | * 1 = user |
||
28 | * 2 = admin |
||
29 | * 3 = disabled |
||
30 | * 4 = moderator |
||
31 | * |
||
32 | * Admins and mods should be the only ones to see admin content. |
||
33 | */ |
||
34 | $this->smarty->assign('admin', (($role === 2 || $role === 4) ? 'true' : 'false')); |
||
35 | |||
36 | $contentId = 0; |
||
37 | if ($request->has('id')) { |
||
38 | $contentId = $request->input('id'); |
||
39 | } |
||
40 | |||
41 | $contentPage = false; |
||
42 | if ($request->has('page')) { |
||
43 | $contentPage = $request->input('page'); |
||
44 | } |
||
45 | |||
46 | if ($contentId === 0 && $contentPage === 'content') { |
||
47 | $content = $contents->getAllButFront(); |
||
48 | $this->smarty->assign('front', false); |
||
49 | $meta_title = 'Contents page'; |
||
50 | $meta_keywords = 'contents'; |
||
51 | $meta_description = 'This is the contents page.'; |
||
52 | } elseif ($contentId !== 0 && $contentPage !== false) { |
||
53 | $content = [$contents->getByID($contentId, $role)]; |
||
54 | $this->smarty->assign('front', false); |
||
55 | $meta_title = 'Contents page'; |
||
56 | $meta_keywords = 'contents'; |
||
57 | $meta_description = 'This is the contents page.'; |
||
58 | } else { |
||
59 | $content = $contents->getFrontPage(); |
||
60 | $index = $contents->getIndex(); |
||
61 | $this->smarty->assign('front', true); |
||
62 | $meta_title = $index->title ?? 'Contents page'; |
||
63 | $meta_keywords = $index->metakeyword ?? 'contents'; |
||
64 | $meta_description = $index->metadescription ?? 'This is the contents page.'; |
||
65 | } |
||
66 | |||
67 | if (empty($content)) { |
||
68 | return response()->json(['message' => 'There is nothing to see here, no content provided.'], 404); |
||
69 | } |
||
70 | |||
71 | $this->smarty->assign('content', $content); |
||
72 | |||
73 | $content = $this->smarty->fetch('content.tpl'); |
||
74 | $this->smarty->assign(compact('content', 'meta_title', 'meta_keywords', 'meta_description')); |
||
75 | $this->pagerender(); |
||
76 | } |
||
78 |
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