| Conditions | 10 |
| Paths | 16 |
| Total Lines | 29 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 |
||
| 61 | public function getPageViews() |
||
| 62 | { |
||
| 63 | $templates = $this->where('active', 1)->where('type', 'default')->get(); |
||
| 64 | $pageViews = []; |
||
| 65 | foreach ($templates as $template) { |
||
| 66 | if (file_exists(base_path('vendor/' . $template->path . '/src/views/templates/' . $template->slug))) { |
||
| 67 | $pageDir = array_slice(scandir(base_path('vendor/' . $template->path . '/src/views/templates/' . $template->slug)), 2); |
||
| 68 | if (count($pageDir) > 0) { |
||
| 69 | $pageViews[$template->slug]['hintpath'] = $template->hintpath; |
||
| 70 | foreach ($pageDir as $pdKey => $pdValue) { |
||
| 71 | if (strpos($pdValue, '.blade.php')) { |
||
| 72 | $pageViews[$template->slug]['files'][] = str_replace('.blade.php', '', $pdValue); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | } |
||
| 76 | } |
||
| 77 | if (file_exists(base_path('resources/views/vendor/' . $template->slug . '/templates/' . $template->slug))) { |
||
| 78 | $pageDir = array_slice(scandir(base_path('resources/views/vendor/' . $template->slug . '/templates/' . $template->slug)), 2); |
||
| 79 | if (count($pageDir) > 0) { |
||
| 80 | $pageViews[$template->slug]['hintpath'] = $template->hintpath; |
||
| 81 | foreach ($pageDir as $pdKey => $pdValue) { |
||
| 82 | if (strpos($pdValue, '.blade.php')) { |
||
| 83 | $pageViews[$template->slug]['files'][] = str_replace('.blade.php', '', $pdValue); |
||
| 84 | } |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | return $pageViews; |
||
| 90 | } |
||
| 130 |