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