Conditions | 10 |
Paths | 16 |
Total Lines | 30 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
31 | public function getEmailTemplates() |
||
32 | { |
||
33 | $templates = $this->where('active', 1)->where('type', 'default')->get(); |
||
34 | $emailTemplates = []; |
||
35 | foreach ($templates as $template) { |
||
36 | if (file_exists(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug.'/mails'))) { |
||
37 | $mailDir = array_slice(scandir(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug.'/mails')), 2); |
||
38 | if (count($mailDir) > 0) { |
||
39 | $emailTemplates[$template->slug]['hintpath'] = $template->hintpath; |
||
40 | foreach ($mailDir as $mdKey => $mdValue) { |
||
41 | if (strpos($mdValue, '.blade.php')) { |
||
42 | $emailTemplates[$template->slug]['files'][] = str_replace('.blade.php', '', $mdValue); |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 | } |
||
47 | if (file_exists(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug.'/mails'))) { |
||
48 | $mailDirVendor = array_slice(scandir(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug.'/mails')), 2); |
||
49 | if (count($mailDirVendor) > 0) { |
||
50 | $emailTemplates[$template->slug]['hintpath'] = $template->hintpath; |
||
51 | foreach ($mailDirVendor as $mdKey => $mdValue) { |
||
52 | if (strpos($mdValue, '.blade.php')) { |
||
53 | $emailTemplates[$template->slug]['files'][] = str_replace('.blade.php', '', $mdValue); |
||
54 | } |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 | |||
60 | return $emailTemplates; |
||
61 | } |
||
146 |