| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 39 |
| 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 |
||
| 118 | protected function fileDataset(): array |
||
| 119 | { |
||
| 120 | return [ |
||
| 121 | 'files' => [ // simple upload |
||
| 122 | 'name' => 'facepalm.jpg', |
||
| 123 | 'type' => 'image/jpeg', |
||
| 124 | 'tmp_name' => '/tmp/php3zU3t5', |
||
| 125 | 'error' => UPLOAD_ERR_OK, |
||
| 126 | 'size' => 591387, |
||
| 127 | ], |
||
| 128 | 'download' => [ // multiple upload |
||
| 129 | 'name' => [ |
||
| 130 | 'file1' => 'MyFile.txt', |
||
| 131 | 'file2' => 'MyFile.jpg', |
||
| 132 | ], |
||
| 133 | 'type' => [ |
||
| 134 | 'file1' => 'text/plain', |
||
| 135 | 'file2' => 'image/jpeg', |
||
| 136 | ], |
||
| 137 | 'tmp_name' => [ |
||
| 138 | 'file1' => '/tmp/php/phpgj46fg', |
||
| 139 | 'file2' => '/tmp/php/php7s4ag4', |
||
| 140 | ], |
||
| 141 | 'error' => [ |
||
| 142 | 'file1' => UPLOAD_ERR_CANT_WRITE, |
||
| 143 | 'file2' => UPLOAD_ERR_PARTIAL, |
||
| 144 | ], |
||
| 145 | 'size' => [ |
||
| 146 | 'file1' => 816, |
||
| 147 | 'file2' => 3075, |
||
| 148 | ], |
||
| 149 | ], |
||
| 150 | 'numbered' => [ // multiple upload |
||
| 151 | 'name' => [ |
||
| 152 | 0 => 'MyFile.txt', |
||
| 153 | 1 => 'MyFile.jpg', |
||
| 154 | ], |
||
| 155 | 'type' => [ |
||
| 156 | 0 => 'text/plain', |
||
| 157 | 1 => 'image/jpeg', |
||
| 158 | ], |
||
| 159 | 'tmp_name' => [ |
||
| 160 | 0 => '/tmp/php/phpgj46fg', |
||
| 161 | 1 => '/tmp/php/php7s4ag4', |
||
| 162 | ], |
||
| 163 | 'error' => [ |
||
| 164 | 0 => UPLOAD_ERR_CANT_WRITE, |
||
| 165 | 1 => UPLOAD_ERR_PARTIAL, |
||
| 166 | ], |
||
| 167 | 'size' => [ |
||
| 168 | 0 => 816, |
||
| 169 | 1 => 3075, |
||
| 170 | ], |
||
| 176 |