| Conditions | 1 |
| Paths | 1 |
| Total Lines | 414 |
| Code Lines | 271 |
| 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 |
||
| 12 | public function parseProvider() |
||
| 13 | { |
||
| 14 | return [ |
||
| 15 | 'application/ogg;description=Hello there!;asd=fgh' => [ |
||
| 16 | 'application/ogg;description=Hello there!;asd=fgh', |
||
| 17 | [ |
||
| 18 | 'application/ogg', |
||
| 19 | 'application/ogg; description="Hello there!"; asd="fgh"', |
||
| 20 | 'application/ogg; description="Hello there!"; asd="fgh"', |
||
| 21 | ], |
||
| 22 | ['application', null], |
||
| 23 | ['ogg', null], |
||
| 24 | true, |
||
| 25 | [ |
||
| 26 | 'description' => ['Hello there!', null], |
||
| 27 | 'asd' => ['fgh', null], |
||
| 28 | ], |
||
| 29 | ], |
||
| 30 | 'text/plain' => [ |
||
| 31 | 'text/plain', |
||
| 32 | [ |
||
| 33 | 'text/plain', |
||
| 34 | 'text/plain', |
||
| 35 | 'text/plain', |
||
| 36 | ], |
||
| 37 | ['text', null], |
||
| 38 | ['plain', null], |
||
| 39 | false, |
||
| 40 | [], |
||
| 41 | ], |
||
| 42 | 'text/plain;a=b' => [ |
||
| 43 | 'text/plain;a=b', |
||
| 44 | [ |
||
| 45 | 'text/plain', |
||
| 46 | 'text/plain; a="b"', |
||
| 47 | 'text/plain; a="b"', |
||
| 48 | ], |
||
| 49 | ['text', null], |
||
| 50 | ['plain', null], |
||
| 51 | true, |
||
| 52 | [ |
||
| 53 | 'a' => ['b', null], |
||
| 54 | ], |
||
| 55 | ], |
||
| 56 | 'application/ogg' => [ |
||
| 57 | 'application/ogg', |
||
| 58 | [ |
||
| 59 | 'application/ogg', |
||
| 60 | 'application/ogg', |
||
| 61 | 'application/ogg', |
||
| 62 | ], |
||
| 63 | ['application', null], |
||
| 64 | ['ogg', null], |
||
| 65 | false, |
||
| 66 | [], |
||
| 67 | ], |
||
| 68 | '*/*' => [ |
||
| 69 | '*/*', |
||
| 70 | [ |
||
| 71 | '*/*', |
||
| 72 | '*/*', |
||
| 73 | '*/*', |
||
| 74 | ], |
||
| 75 | ['*', null], |
||
| 76 | ['*', null], |
||
| 77 | false, |
||
| 78 | [], |
||
| 79 | ], |
||
| 80 | 'n/n' => [ |
||
| 81 | 'n/n', |
||
| 82 | [ |
||
| 83 | 'n/n', |
||
| 84 | 'n/n', |
||
| 85 | 'n/n', |
||
| 86 | ], |
||
| 87 | ['n', null], |
||
| 88 | ['n', null], |
||
| 89 | false, |
||
| 90 | [], |
||
| 91 | ], |
||
| 92 | '(UTF-8 Plain Text) text / plain ; charset = utf-8' => [ |
||
| 93 | '(UTF-8 Plain Text) text / plain ; charset = utf-8', |
||
| 94 | [ |
||
| 95 | 'text/plain', |
||
| 96 | 'text/plain; charset="utf-8"', |
||
| 97 | 'text (UTF-8 Plain Text)/plain; charset="utf-8"', |
||
| 98 | ], |
||
| 99 | ['text', 'UTF-8 Plain Text'], |
||
| 100 | ['plain', null], |
||
| 101 | true, |
||
| 102 | [ |
||
| 103 | 'charset' => ['utf-8', null], |
||
| 104 | ], |
||
| 105 | ], |
||
| 106 | 'text (Text) / plain ; charset = utf-8' => [ |
||
| 107 | 'text (Text) / plain ; charset = utf-8', |
||
| 108 | [ |
||
| 109 | 'text/plain', |
||
| 110 | 'text/plain; charset="utf-8"', |
||
| 111 | 'text (Text)/plain; charset="utf-8"', |
||
| 112 | ], |
||
| 113 | ['text', 'Text'], |
||
| 114 | ['plain', null], |
||
| 115 | true, |
||
| 116 | [ |
||
| 117 | 'charset' => ['utf-8', null], |
||
| 118 | ], |
||
| 119 | ], |
||
| 120 | 'text / (Plain) plain ; charset = utf-8' => [ |
||
| 121 | 'text / (Plain) plain ; charset = utf-8', |
||
| 122 | [ |
||
| 123 | 'text/plain', |
||
| 124 | 'text/plain; charset="utf-8"', |
||
| 125 | 'text/plain (Plain); charset="utf-8"', |
||
| 126 | ], |
||
| 127 | ['text', null], |
||
| 128 | ['plain', 'Plain'], |
||
| 129 | true, |
||
| 130 | [ |
||
| 131 | 'charset' => ['utf-8', null], |
||
| 132 | ], |
||
| 133 | ], |
||
| 134 | 'text / plain (Plain Text) ; charset = utf-8' => [ |
||
| 135 | 'text / plain (Plain Text) ; charset = utf-8', |
||
| 136 | [ |
||
| 137 | 'text/plain', |
||
| 138 | 'text/plain; charset="utf-8"', |
||
| 139 | 'text/plain (Plain Text); charset="utf-8"', |
||
| 140 | ], |
||
| 141 | ['text', null], |
||
| 142 | ['plain', 'Plain Text'], |
||
| 143 | true, |
||
| 144 | [ |
||
| 145 | 'charset' => ['utf-8', null], |
||
| 146 | ], |
||
| 147 | ], |
||
| 148 | 'text / plain ; (Charset=utf-8) charset = utf-8' => [ |
||
| 149 | 'text / plain ; (Charset=utf-8) charset = utf-8', |
||
| 150 | [ |
||
| 151 | 'text/plain', |
||
| 152 | 'text/plain; charset="utf-8"', |
||
| 153 | 'text/plain; charset="utf-8" (Charset=utf-8)', |
||
| 154 | ], |
||
| 155 | ['text', null], |
||
| 156 | ['plain', null], |
||
| 157 | true, |
||
| 158 | [ |
||
| 159 | 'charset' => ['utf-8', 'Charset=utf-8'], |
||
| 160 | ], |
||
| 161 | ], |
||
| 162 | 'text / plain ; charset (Charset) = utf-8' => [ |
||
| 163 | 'text / plain ; charset (Charset) = utf-8', |
||
| 164 | [ |
||
| 165 | 'text/plain', |
||
| 166 | 'text/plain; charset="utf-8"', |
||
| 167 | 'text/plain; charset="utf-8" (Charset)', |
||
| 168 | ], |
||
| 169 | ['text', null], |
||
| 170 | ['plain', null], |
||
| 171 | true, |
||
| 172 | [ |
||
| 173 | 'charset' => ['utf-8', 'Charset'], |
||
| 174 | ], |
||
| 175 | ], |
||
| 176 | 'text / plain ; charset = (UTF8) utf-8' => [ |
||
| 177 | 'text / plain ; charset = (UTF8) utf-8', |
||
| 178 | [ |
||
| 179 | 'text/plain', |
||
| 180 | 'text/plain; charset="utf-8"', |
||
| 181 | 'text/plain; charset="utf-8" (UTF8)', |
||
| 182 | ], |
||
| 183 | ['text', null], |
||
| 184 | ['plain', null], |
||
| 185 | true, |
||
| 186 | [ |
||
| 187 | 'charset' => ['utf-8', 'UTF8'], |
||
| 188 | ], |
||
| 189 | ], |
||
| 190 | 'text / plain ; charset = utf-8 (UTF-8 Plain Text)' => [ |
||
| 191 | 'text / plain ; charset = utf-8 (UTF-8 Plain Text)', |
||
| 192 | [ |
||
| 193 | 'text/plain', |
||
| 194 | 'text/plain; charset="utf-8"', |
||
| 195 | 'text/plain; charset="utf-8" (UTF-8 Plain Text)', |
||
| 196 | ], |
||
| 197 | ['text', null], |
||
| 198 | ['plain', null], |
||
| 199 | true, |
||
| 200 | [ |
||
| 201 | 'charset' => ['utf-8', 'UTF-8 Plain Text'], |
||
| 202 | ], |
||
| 203 | ], |
||
| 204 | 'application/x-foobar;description="bbgh(kdur"' => [ |
||
| 205 | 'application/x-foobar;description="bbgh(kdur"', |
||
| 206 | [ |
||
| 207 | 'application/x-foobar', |
||
| 208 | 'application/x-foobar; description="bbgh(kdur"', |
||
| 209 | 'application/x-foobar; description="bbgh(kdur"', |
||
| 210 | ], |
||
| 211 | ['application', null], |
||
| 212 | ['x-foobar', null], |
||
| 213 | true, |
||
| 214 | [ |
||
| 215 | 'description' => ['bbgh(kdur', null], |
||
| 216 | ], |
||
| 217 | ], |
||
| 218 | 'application/x-foobar;description="a \"quoted string\""' => [ |
||
| 219 | 'application/x-foobar;description="a \"quoted string\""', |
||
| 220 | [ |
||
| 221 | 'application/x-foobar', |
||
| 222 | 'application/x-foobar; description="a \"quoted string\""', |
||
| 223 | 'application/x-foobar; description="a \"quoted string\""', |
||
| 224 | ], |
||
| 225 | ['application', null], |
||
| 226 | ['x-foobar', null], |
||
| 227 | true, |
||
| 228 | [ |
||
| 229 | 'description' => ['a "quoted string"', null], |
||
| 230 | ], |
||
| 231 | ], |
||
| 232 | 'text/xml;description=test' => [ |
||
| 233 | 'text/xml;description=test', |
||
| 234 | [ |
||
| 235 | 'text/xml', |
||
| 236 | 'text/xml; description="test"', |
||
| 237 | 'text/xml; description="test"', |
||
| 238 | ], |
||
| 239 | ['text', null], |
||
| 240 | ['xml', null], |
||
| 241 | true, |
||
| 242 | [ |
||
| 243 | 'description' => ['test', null], |
||
| 244 | ], |
||
| 245 | ], |
||
| 246 | 'text/xml;one=test;two=three' => [ |
||
| 247 | 'text/xml;one=test;two=three', |
||
| 248 | [ |
||
| 249 | 'text/xml', |
||
| 250 | 'text/xml; one="test"; two="three"', |
||
| 251 | 'text/xml; one="test"; two="three"', |
||
| 252 | ], |
||
| 253 | ['text', null], |
||
| 254 | ['xml', null], |
||
| 255 | true, |
||
| 256 | [ |
||
| 257 | 'one' => ['test', null], |
||
| 258 | 'two' => ['three', null], |
||
| 259 | ], |
||
| 260 | ], |
||
| 261 | 'text/xml;one="test";two="three"' => [ |
||
| 262 | 'text/xml;one="test";two="three"', |
||
| 263 | [ |
||
| 264 | 'text/xml', |
||
| 265 | 'text/xml; one="test"; two="three"', |
||
| 266 | 'text/xml; one="test"; two="three"', |
||
| 267 | ], |
||
| 268 | ['text', null], |
||
| 269 | ['xml', null], |
||
| 270 | true, |
||
| 271 | [ |
||
| 272 | 'one' => ['test', null], |
||
| 273 | 'two' => ['three', null], |
||
| 274 | ], |
||
| 275 | ], |
||
| 276 | 'text/xml; this="is"; a="parameter" (with a comment)' => [ |
||
| 277 | 'text/xml; this="is"; a="parameter" (with a comment)', |
||
| 278 | [ |
||
| 279 | 'text/xml', |
||
| 280 | 'text/xml; this="is"; a="parameter"', |
||
| 281 | 'text/xml; this="is"; a="parameter" (with a comment)', |
||
| 282 | ], |
||
| 283 | ['text', null], |
||
| 284 | ['xml', null], |
||
| 285 | true, |
||
| 286 | [ |
||
| 287 | 'this' => ['is', null], |
||
| 288 | 'a' => ['parameter', 'with a comment'], |
||
| 289 | ], |
||
| 290 | ], |
||
| 291 | // Various edge cases. |
||
| 292 | 'null' => [ |
||
| 293 | null, |
||
| 294 | [ |
||
| 295 | null, |
||
| 296 | null, |
||
| 297 | null, |
||
| 298 | ], |
||
| 299 | [null, null], |
||
| 300 | [null, null], |
||
| 301 | false, |
||
| 302 | [], |
||
| 303 | ], |
||
| 304 | 'text/plain; charset="utf-8" (UTF/8)' => [ |
||
| 305 | 'text/plain; charset="utf-8" (UTF/8)', |
||
| 306 | [ |
||
| 307 | 'text/plain', |
||
| 308 | 'text/plain; charset="utf-8"', |
||
| 309 | 'text/plain; charset="utf-8" (UTF/8)', |
||
| 310 | ], |
||
| 311 | ['text', null], |
||
| 312 | ['plain', null], |
||
| 313 | true, |
||
| 314 | [ |
||
| 315 | 'charset' => ['utf-8', 'UTF/8'], |
||
| 316 | ], |
||
| 317 | ], |
||
| 318 | 'appf/xml; a=b; b="parameter" (with; a comment) ;c=d; e=f (;) ; g=h ' => [ |
||
| 319 | 'appf/xml; a=b; b="parameter" (with; a comment) ;c=d; e=f (;) ; g=h ', |
||
| 320 | [ |
||
| 321 | 'appf/xml', |
||
| 322 | 'appf/xml; a="b"; b="parameter"; c="d"; e="f"; g="h"', |
||
| 323 | 'appf/xml; a="b"; b="parameter" (with; a comment); c="d"; e="f" (;); g="h"', |
||
| 324 | ], |
||
| 325 | ['appf', null], |
||
| 326 | ['xml', null], |
||
| 327 | true, |
||
| 328 | [ |
||
| 329 | 'a' => ['b', null], |
||
| 330 | 'b' => ['parameter', 'with; a comment'], |
||
| 331 | 'c' => ['d', null], |
||
| 332 | 'e' => ['f', ';'], |
||
| 333 | 'g' => ['h', null], |
||
| 334 | ], |
||
| 335 | ], |
||
| 336 | 'text/(abc)def(ghi)' => [ |
||
| 337 | 'text/(abc)def(ghi)', |
||
| 338 | [ |
||
| 339 | 'text/def', |
||
| 340 | 'text/def', |
||
| 341 | 'text/def (abc ghi)', |
||
| 342 | ], |
||
| 343 | ['text', null], |
||
| 344 | ['def', 'abc ghi'], |
||
| 345 | false, |
||
| 346 | [], |
||
| 347 | ], |
||
| 348 | 'text/(abc)def' => [ |
||
| 349 | 'text/(abc)def', |
||
| 350 | [ |
||
| 351 | 'text/def', |
||
| 352 | 'text/def', |
||
| 353 | 'text/def (abc)', |
||
| 354 | ], |
||
| 355 | ['text', null], |
||
| 356 | ['def', 'abc'], |
||
| 357 | false, |
||
| 358 | [], |
||
| 359 | ], |
||
| 360 | 'text/def(ghi)' => [ |
||
| 361 | 'text/def(ghi)', |
||
| 362 | [ |
||
| 363 | 'text/def', |
||
| 364 | 'text/def', |
||
| 365 | 'text/def (ghi)', |
||
| 366 | ], |
||
| 367 | ['text', null], |
||
| 368 | ['def', 'ghi'], |
||
| 369 | false, |
||
| 370 | [], |
||
| 371 | ], |
||
| 372 | 'text/plain;a=(\)abc)def(\()' => [ |
||
| 373 | 'text/plain;a=(\)abc)def(\()', |
||
| 374 | [ |
||
| 375 | 'text/plain', |
||
| 376 | 'text/plain; a="def"', |
||
| 377 | 'text/plain; a="def" (\)abc \()', |
||
| 378 | ], |
||
| 379 | ['text', null], |
||
| 380 | ['plain', null], |
||
| 381 | true, |
||
| 382 | [ |
||
| 383 | 'a' => ['def', '\)abc \('], |
||
| 384 | ], |
||
| 385 | ], |
||
| 386 | 'text/plain;a=\\foo(abc)' => [ |
||
| 387 | 'text/plain;a=\\foo(abc)', |
||
| 388 | [ |
||
| 389 | 'text/plain', |
||
| 390 | 'text/plain; a="foo"', |
||
| 391 | 'text/plain; a="foo" (abc)', |
||
| 392 | ], |
||
| 393 | ['text', null], |
||
| 394 | ['plain', null], |
||
| 395 | true, |
||
| 396 | [ |
||
| 397 | 'a' => ['foo', 'abc'], |
||
| 398 | ], |
||
| 399 | ], |
||
| 400 | 'text/plain;a=(a"bc\)def")def' => [ |
||
| 401 | 'text/plain;a=(a"bc\)def")def', |
||
| 402 | [ |
||
| 403 | 'text/plain', |
||
| 404 | 'text/plain; a="def"', |
||
| 405 | 'text/plain; a="def" (a"bc\)def")', |
||
| 406 | ], |
||
| 407 | ['text', null], |
||
| 408 | ['plain', null], |
||
| 409 | true, |
||
| 410 | [ |
||
| 411 | 'a' => ['def', 'a"bc\)def"'], |
||
| 412 | ], |
||
| 413 | ], |
||
| 414 | 'text/plain;a="(abc)def"' => [ |
||
| 415 | 'text/plain;a="(abc)def"', |
||
| 416 | [ |
||
| 417 | 'text/plain', |
||
| 418 | 'text/plain; a="(abc)def"', |
||
| 419 | 'text/plain; a="(abc)def"', |
||
| 420 | ], |
||
| 421 | ['text', null], |
||
| 422 | ['plain', null], |
||
| 423 | true, |
||
| 424 | [ |
||
| 425 | 'a' => ['(abc)def', null], |
||
| 426 | ], |
||
| 663 |