| Conditions | 25 |
| Paths | 511 |
| Total Lines | 90 |
| Lines | 40 |
| Ratio | 44.44 % |
| Changes | 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 |
||
| 56 | function xoops_module_install_xnewsletter(\XoopsModule $module) |
||
| 57 | { |
||
| 58 | require_once dirname(__DIR__) . '/preloads/autoloader.php'; |
||
| 59 | |||
| 60 | // get module config values |
||
| 61 | $hModConfig = xoops_getHandler('config'); |
||
| 62 | $configArray = $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
||
| 63 | |||
| 64 | //Creation of folder "uploads" for the module to the site root |
||
| 65 | $path = XOOPS_ROOT_PATH . '/uploads/xnewsletter'; |
||
| 66 | View Code Duplication | if (!is_dir($path)) { |
|
| 67 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 68 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | chmod($path, 0777); |
||
| 72 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 73 | |||
| 74 | //Creation of the file accounts in uploads directory |
||
| 75 | $path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/accounts'; |
||
| 76 | View Code Duplication | if (!is_dir($path)) { |
|
| 77 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 78 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | chmod($path, 0777); |
||
| 82 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 83 | |||
| 84 | //Creation of the file cat in uploads directory |
||
| 85 | $path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/cat'; |
||
| 86 | View Code Duplication | if (!is_dir($path)) { |
|
| 87 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 88 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 89 | } |
||
| 90 | } |
||
| 91 | chmod($path, 0777); |
||
| 92 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 93 | |||
| 94 | //Creation of the file subscr in uploads directory |
||
| 95 | $path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/subscr'; |
||
| 96 | View Code Duplication | if (!is_dir($path)) { |
|
| 97 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 98 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 99 | } |
||
| 100 | } |
||
| 101 | chmod($path, 0777); |
||
| 102 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 103 | |||
| 104 | //Creation of the file catsubscr in uploads directory |
||
| 105 | $path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/catsubscr'; |
||
| 106 | View Code Duplication | if (!is_dir($path)) { |
|
| 107 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 108 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | chmod($path, 0777); |
||
| 112 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 113 | |||
| 114 | //Creation of the file letter in uploads directory |
||
| 115 | $path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/letter'; |
||
| 116 | View Code Duplication | if (!is_dir($path)) { |
|
| 117 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 118 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 119 | } |
||
| 120 | } |
||
| 121 | chmod($path, 0777); |
||
| 122 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 123 | |||
| 124 | //Creation of the file protocol in uploads directory |
||
| 125 | $path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/protocol'; |
||
| 126 | View Code Duplication | if (!is_dir($path)) { |
|
| 127 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 128 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 129 | } |
||
| 130 | } |
||
| 131 | chmod($path, 0777); |
||
| 132 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 133 | |||
| 134 | //Creation of the folder letter_attachment in uploads directory for files |
||
| 135 | $path = XOOPS_ROOT_PATH . '/uploads' . $configArray['xn_attachment_path']; |
||
| 136 | View Code Duplication | if (!is_dir($path)) { |
|
| 137 | if (!mkdir($path, 0777, true) && !is_dir($path)) { |
||
| 138 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||
| 139 | } |
||
| 140 | } |
||
| 141 | chmod($path, 0777); |
||
| 142 | copy(INDEX_FILE_PATH, $path . '/index.html'); |
||
| 143 | |||
| 144 | return true; |
||
| 145 | } |
||
| 146 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.