Conditions | 14 |
Paths | 46 |
Total Lines | 41 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 2 | Features | 1 |
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 |
||
63 | public function getPageViews() |
||
64 | { |
||
65 | $templates = $this->where('active', 1)->get(); |
||
66 | $pageViews = []; |
||
67 | foreach ($templates as $template) { |
||
68 | if (file_exists(base_path('packages/'.$template->path.'/src/views/templates/'.$template->slug))) { |
||
69 | $pageDir = array_slice(scandir(base_path('packages/'.$template->path.'/src/views/templates/'.$template->slug)), 2); |
||
70 | if (count($pageDir) > 0) { |
||
71 | $pageViews[$template->slug]['hintpath'] = $template->hintpath; |
||
72 | foreach ($pageDir as $pdKey => $pdValue) { |
||
73 | if (strpos($pdValue, '.blade.php')) { |
||
74 | $pageViews[$template->slug]['files'][] = str_replace('.blade.php', '', $pdValue); |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | } |
||
79 | if (file_exists(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug))) { |
||
80 | $pageDir = array_slice(scandir(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug)), 2); |
||
81 | if (count($pageDir) > 0) { |
||
82 | $pageViews[$template->slug]['hintpath'] = $template->hintpath; |
||
83 | foreach ($pageDir as $pdKey => $pdValue) { |
||
84 | if (strpos($pdValue, '.blade.php')) { |
||
85 | $pageViews[$template->slug]['files'][] = str_replace('.blade.php', '', $pdValue); |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 | } |
||
90 | if (file_exists(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug))) { |
||
91 | $pageDir = array_slice(scandir(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug)), 2); |
||
92 | if (count($pageDir) > 0) { |
||
93 | $pageViews[$template->slug]['hintpath'] = $template->hintpath; |
||
94 | foreach ($pageDir as $pdKey => $pdValue) { |
||
95 | if (strpos($pdValue, '.blade.php')) { |
||
96 | $pageViews[$template->slug]['files'][] = str_replace('.blade.php', '', $pdValue); |
||
97 | } |
||
98 | } |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | |||
103 | return $pageViews; |
||
104 | } |
||
146 |