Conditions | 16 |
Paths | 63 |
Total Lines | 57 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | 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 |
||
68 | function xoops_module_update_lexikon_v152($xoopsModule) |
||
69 | { |
||
70 | /** |
||
71 | * Create default upload directories |
||
72 | */ |
||
73 | // Copy base file |
||
74 | $indexFile = XOOPS_UPLOAD_PATH . '/index.html'; |
||
75 | $blankFile = XOOPS_UPLOAD_PATH . '/blank.gif'; |
||
76 | // Making of uploads/lexikon folder |
||
77 | $p_lexikon = XOOPS_UPLOAD_PATH . '/lexikon'; |
||
78 | if (!is_dir($p_lexikon)) { |
||
79 | if (!mkdir($p_lexikon, 0777) && !is_dir($p_lexikon)) { |
||
80 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $p_lexikon)); |
||
81 | } |
||
82 | chmod($p_lexikon, 0777); |
||
83 | } |
||
84 | copy($indexFile, $p_lexikon . '/index.html'); |
||
85 | // Making of categories folder |
||
86 | $pl_categories = $p_lexikon . '/categories'; |
||
87 | if (!is_dir($pl_categories)) { |
||
88 | if (!mkdir($pl_categories, 0777) && !is_dir($pl_categories)) { |
||
89 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $pl_categories)); |
||
90 | } |
||
91 | chmod($pl_categories, 0777); |
||
92 | } |
||
93 | copy($indexFile, $pl_categories . '/index.html'); |
||
94 | |||
95 | $plc_images = $pl_categories . '/images'; |
||
96 | if (!is_dir($plc_images)) { |
||
97 | if (!mkdir($plc_images, 0777) && !is_dir($plc_images)) { |
||
98 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $plc_images)); |
||
99 | } |
||
100 | chmod($plc_images, 0777); |
||
101 | } |
||
102 | copy($indexFile, $plc_images . '/index.html'); |
||
103 | copy($blankFile, $plc_images . '/blank.gif'); |
||
104 | // Making of entries folder |
||
105 | $pl_entries = $p_lexikon . '/entries'; |
||
106 | if (!is_dir($pl_entries)) { |
||
107 | if (!mkdir($pl_entries, 0777) && !is_dir($pl_entries)) { |
||
108 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $pl_entries)); |
||
109 | } |
||
110 | chmod($pl_entries, 0777); |
||
111 | } |
||
112 | copy($indexFile, $pl_entries . '/index.html'); |
||
113 | |||
114 | $ple_images = $pl_entries . '/images'; |
||
115 | if (!is_dir($ple_images)) { |
||
116 | if (!mkdir($ple_images, 0777) && !is_dir($ple_images)) { |
||
117 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $ple_images)); |
||
118 | } |
||
119 | chmod($ple_images, 0777); |
||
120 | } |
||
121 | copy($indexFile, $ple_images . '/index.html'); |
||
122 | copy($blankFile, $ple_images . '/blank.gif'); |
||
123 | |||
124 | return true; |
||
125 | } |
||
126 |