| Conditions | 1 |
| Paths | 1 |
| Total Lines | 243 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 33 | public function dataNormalizeFiles() |
||
| 34 | { |
||
| 35 | return [ |
||
| 36 | 'Single file' => [ |
||
| 37 | [ |
||
| 38 | 'file' => [ |
||
| 39 | 'name' => 'MyFile.txt', |
||
| 40 | 'type' => 'text/plain', |
||
| 41 | 'tmp_name' => '/tmp/php/php1h4j1o', |
||
| 42 | 'error' => '0', |
||
| 43 | 'size' => '123', |
||
| 44 | ], |
||
| 45 | ], |
||
| 46 | [ |
||
| 47 | 'file' => new UploadedFile( |
||
| 48 | '/tmp/php/php1h4j1o', |
||
| 49 | 123, |
||
| 50 | UPLOAD_ERR_OK, |
||
| 51 | 'MyFile.txt', |
||
| 52 | 'text/plain' |
||
| 53 | ), |
||
| 54 | ], |
||
| 55 | ], |
||
| 56 | 'Empty file' => [ |
||
| 57 | [ |
||
| 58 | 'image_file' => [ |
||
| 59 | 'name' => '', |
||
| 60 | 'type' => '', |
||
| 61 | 'tmp_name' => '', |
||
| 62 | 'error' => '4', |
||
| 63 | 'size' => '0', |
||
| 64 | ], |
||
| 65 | ], |
||
| 66 | [ |
||
| 67 | 'image_file' => new UploadedFile( |
||
| 68 | '', |
||
| 69 | 0, |
||
| 70 | UPLOAD_ERR_NO_FILE, |
||
| 71 | '', |
||
| 72 | '' |
||
| 73 | ), |
||
| 74 | ], |
||
| 75 | ], |
||
| 76 | 'Already Converted' => [ |
||
| 77 | [ |
||
| 78 | 'file' => new UploadedFile( |
||
| 79 | '/tmp/php/php1h4j1o', |
||
| 80 | 123, |
||
| 81 | UPLOAD_ERR_OK, |
||
| 82 | 'MyFile.txt', |
||
| 83 | 'text/plain' |
||
| 84 | ), |
||
| 85 | ], |
||
| 86 | [ |
||
| 87 | 'file' => new UploadedFile( |
||
| 88 | '/tmp/php/php1h4j1o', |
||
| 89 | 123, |
||
| 90 | UPLOAD_ERR_OK, |
||
| 91 | 'MyFile.txt', |
||
| 92 | 'text/plain' |
||
| 93 | ), |
||
| 94 | ], |
||
| 95 | ], |
||
| 96 | 'Already Converted array' => [ |
||
| 97 | [ |
||
| 98 | 'file' => [ |
||
| 99 | new UploadedFile( |
||
| 100 | '/tmp/php/php1h4j1o', |
||
| 101 | 123, |
||
| 102 | UPLOAD_ERR_OK, |
||
| 103 | 'MyFile.txt', |
||
| 104 | 'text/plain' |
||
| 105 | ), |
||
| 106 | new UploadedFile( |
||
| 107 | '', |
||
| 108 | 0, |
||
| 109 | UPLOAD_ERR_NO_FILE, |
||
| 110 | '', |
||
| 111 | '' |
||
| 112 | ), |
||
| 113 | ], |
||
| 114 | ], |
||
| 115 | [ |
||
| 116 | 'file' => [ |
||
| 117 | new UploadedFile( |
||
| 118 | '/tmp/php/php1h4j1o', |
||
| 119 | 123, |
||
| 120 | UPLOAD_ERR_OK, |
||
| 121 | 'MyFile.txt', |
||
| 122 | 'text/plain' |
||
| 123 | ), |
||
| 124 | new UploadedFile( |
||
| 125 | '', |
||
| 126 | 0, |
||
| 127 | UPLOAD_ERR_NO_FILE, |
||
| 128 | '', |
||
| 129 | '' |
||
| 130 | ), |
||
| 131 | ], |
||
| 132 | ], |
||
| 133 | ], |
||
| 134 | 'Multiple files' => [ |
||
| 135 | [ |
||
| 136 | 'text_file' => [ |
||
| 137 | 'name' => 'MyFile.txt', |
||
| 138 | 'type' => 'text/plain', |
||
| 139 | 'tmp_name' => '/tmp/php/php1h4j1o', |
||
| 140 | 'error' => '0', |
||
| 141 | 'size' => '123', |
||
| 142 | ], |
||
| 143 | 'image_file' => [ |
||
| 144 | 'name' => '', |
||
| 145 | 'type' => '', |
||
| 146 | 'tmp_name' => '', |
||
| 147 | 'error' => '4', |
||
| 148 | 'size' => '0', |
||
| 149 | ], |
||
| 150 | ], |
||
| 151 | [ |
||
| 152 | 'text_file' => new UploadedFile( |
||
| 153 | '/tmp/php/php1h4j1o', |
||
| 154 | 123, |
||
| 155 | UPLOAD_ERR_OK, |
||
| 156 | 'MyFile.txt', |
||
| 157 | 'text/plain' |
||
| 158 | ), |
||
| 159 | 'image_file' => new UploadedFile( |
||
| 160 | '', |
||
| 161 | 0, |
||
| 162 | UPLOAD_ERR_NO_FILE, |
||
| 163 | '', |
||
| 164 | '' |
||
| 165 | ), |
||
| 166 | ], |
||
| 167 | ], |
||
| 168 | 'Nested files' => [ |
||
| 169 | [ |
||
| 170 | 'file' => [ |
||
| 171 | 'name' => [ |
||
| 172 | 0 => 'MyFile.txt', |
||
| 173 | 1 => 'Image.png', |
||
| 174 | ], |
||
| 175 | 'type' => [ |
||
| 176 | 0 => 'text/plain', |
||
| 177 | 1 => 'image/png', |
||
| 178 | ], |
||
| 179 | 'tmp_name' => [ |
||
| 180 | 0 => '/tmp/php/hp9hskjhf', |
||
| 181 | 1 => '/tmp/php/php1h4j1o', |
||
| 182 | ], |
||
| 183 | 'error' => [ |
||
| 184 | 0 => '0', |
||
| 185 | 1 => '0', |
||
| 186 | ], |
||
| 187 | 'size' => [ |
||
| 188 | 0 => '123', |
||
| 189 | 1 => '7349', |
||
| 190 | ], |
||
| 191 | ], |
||
| 192 | 'nested' => [ |
||
| 193 | 'name' => [ |
||
| 194 | 'other' => 'Flag.txt', |
||
| 195 | 'test' => [ |
||
| 196 | 0 => 'Stuff.txt', |
||
| 197 | 1 => '', |
||
| 198 | ], |
||
| 199 | ], |
||
| 200 | 'type' => [ |
||
| 201 | 'other' => 'text/plain', |
||
| 202 | 'test' => [ |
||
| 203 | 0 => 'text/plain', |
||
| 204 | 1 => '', |
||
| 205 | ], |
||
| 206 | ], |
||
| 207 | 'tmp_name' => [ |
||
| 208 | 'other' => '/tmp/php/hp9hskjhf', |
||
| 209 | 'test' => [ |
||
| 210 | 0 => '/tmp/php/asifu2gp3', |
||
| 211 | 1 => '', |
||
| 212 | ], |
||
| 213 | ], |
||
| 214 | 'error' => [ |
||
| 215 | 'other' => '0', |
||
| 216 | 'test' => [ |
||
| 217 | 0 => '0', |
||
| 218 | 1 => '4', |
||
| 219 | ], |
||
| 220 | ], |
||
| 221 | 'size' => [ |
||
| 222 | 'other' => '421', |
||
| 223 | 'test' => [ |
||
| 224 | 0 => '32', |
||
| 225 | 1 => '0', |
||
| 226 | ], |
||
| 227 | ], |
||
| 228 | ], |
||
| 229 | ], |
||
| 230 | [ |
||
| 231 | 'file' => [ |
||
| 232 | 0 => new UploadedFile( |
||
| 233 | '/tmp/php/hp9hskjhf', |
||
| 234 | 123, |
||
| 235 | UPLOAD_ERR_OK, |
||
| 236 | 'MyFile.txt', |
||
| 237 | 'text/plain' |
||
| 238 | ), |
||
| 239 | 1 => new UploadedFile( |
||
| 240 | '/tmp/php/php1h4j1o', |
||
| 241 | 7349, |
||
| 242 | UPLOAD_ERR_OK, |
||
| 243 | 'Image.png', |
||
| 244 | 'image/png' |
||
| 245 | ), |
||
| 246 | ], |
||
| 247 | 'nested' => [ |
||
| 248 | 'other' => new UploadedFile( |
||
| 249 | '/tmp/php/hp9hskjhf', |
||
| 250 | 421, |
||
| 251 | UPLOAD_ERR_OK, |
||
| 252 | 'Flag.txt', |
||
| 253 | 'text/plain' |
||
| 254 | ), |
||
| 255 | 'test' => [ |
||
| 256 | 0 => new UploadedFile( |
||
| 257 | '/tmp/php/asifu2gp3', |
||
| 258 | 32, |
||
| 259 | UPLOAD_ERR_OK, |
||
| 260 | 'Stuff.txt', |
||
| 261 | 'text/plain' |
||
| 262 | ), |
||
| 263 | 1 => new UploadedFile( |
||
| 264 | '', |
||
| 265 | 0, |
||
| 266 | UPLOAD_ERR_NO_FILE, |
||
| 267 | '', |
||
| 268 | '' |
||
| 269 | ), |
||
| 270 | ], |
||
| 271 | ], |
||
| 272 | ], |
||
| 273 | ], |
||
| 274 | ]; |
||
| 275 | } |
||
| 276 | |||
| 452 |