| Conditions | 2 |
| Paths | 2 |
| Total Lines | 52 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 104 | public function update() |
||
| 105 | { |
||
| 106 | // if ($this->validateUpdate()) { |
||
| 107 | |||
| 108 | // function body |
||
| 109 | // creating working directory |
||
| 110 | if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/storage/update/test')) { |
||
| 111 | mkdir($_SERVER['DOCUMENT_ROOT'] . '/storage/update/test'); |
||
| 112 | } |
||
| 113 | |||
| 114 | // set full file path |
||
| 115 | $file_core_old = ($_SERVER['DOCUMENT_ROOT'] . '/file_core_old.txt'); |
||
| 116 | $file_core_new = ($_SERVER['DOCUMENT_ROOT'] . '/storage/update/test/file_core_new.txt'); |
||
| 117 | $file_result_diff = ($_SERVER['DOCUMENT_ROOT'] . '/file_result_diff.diff'); |
||
| 118 | $file_result_diff_content = file_get_contents(($_SERVER['DOCUMENT_ROOT'] . '/file_result_diff.diff')); |
||
| 119 | $file_core_new_test = ($_SERVER['DOCUMENT_ROOT'] . '/storage/update/test/file_core_new_test.txt'); |
||
| 120 | |||
| 121 | // v1. generate diff with SebastianBergmann\Diff\Differ |
||
| 122 | $cl_differ = new \Differ(); |
||
| 123 | $file_result_diff_to_file = $cl_differ->diff(file_get_contents($file_core_old), file_get_contents($file_core_new)); |
||
| 124 | |||
| 125 | // write generated result to the target file |
||
| 126 | // file_put_contents($file_result_diff, $file_result_diff_to_file); |
||
| 127 | // or |
||
| 128 | $fd = fopen($file_result_diff, 'w+'); |
||
| 129 | fwrite($fd, $file_result_diff_to_file); |
||
| 130 | fclose($fd); |
||
| 131 | |||
| 132 | // https://github.com/yetanotherape/diff-match-patch |
||
| 133 | $dmp = new \DiffMatchPatch(); |
||
| 134 | $patches = $dmp->patch_make( |
||
| 135 | file_get_contents($file_core_old), |
||
| 136 | file_get_contents($file_core_new) |
||
| 137 | ); |
||
| 138 | $result = $dmp->patch_apply($patches, '1'); |
||
| 139 | $result = $result[0]; |
||
| 140 | |||
| 141 | // write patched result to the target file |
||
| 142 | $fd = fopen($file_core_new_test, 'w+'); |
||
| 143 | fwrite($fd, $result); |
||
| 144 | fclose($fd); |
||
| 145 | |||
| 146 | // \Tracy\Debugger::barDump($patches); |
||
| 147 | // \Tracy\Debugger::barDump($result); |
||
| 148 | |||
| 149 | // \Tracy\Debugger::barDump(); |
||
| 150 | |||
| 151 | // alert success after function exec |
||
| 152 | $this->session->data['success'] = $this->language->get('text_success'); |
||
| 153 | |||
| 154 | // redirect to main module page after function exec |
||
| 155 | $this->response->redirect($this->url->link('tool/updater', 'token=' . $this->session->data['token'], true)); |
||
| 156 | // } |
||
| 169 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths