| Conditions | 1 |
| Paths | 1 |
| Total Lines | 279 |
| 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 |
||
| 14 | public function parseProvider() |
||
| 15 | { |
||
| 16 | return [ |
||
| 17 | 'application/ogg;description=Hello there!;asd=fgh' => [ |
||
| 18 | 'application/ogg;description=Hello there!;asd=fgh', |
||
| 19 | 'application/ogg; description="Hello there!"; asd="fgh"', |
||
| 20 | ['application', null], |
||
| 21 | ['ogg', null], |
||
| 22 | true, |
||
| 23 | [ |
||
| 24 | 'description' => ['Hello there!', null], |
||
| 25 | 'asd' => ['fgh', null], |
||
| 26 | ], |
||
| 27 | ], |
||
| 28 | 'text/plain' => [ |
||
| 29 | 'text/plain', |
||
| 30 | 'text/plain', |
||
| 31 | ['text', null], |
||
| 32 | ['plain', null], |
||
| 33 | false, |
||
| 34 | [], |
||
| 35 | ], |
||
| 36 | 'text/plain;a=b' => [ |
||
| 37 | 'text/plain;a=b', |
||
| 38 | 'text/plain; a="b"', |
||
| 39 | ['text', null], |
||
| 40 | ['plain', null], |
||
| 41 | true, |
||
| 42 | [ |
||
| 43 | 'a' => ['b', null], |
||
| 44 | ], |
||
| 45 | ], |
||
| 46 | 'application/ogg' => [ |
||
| 47 | 'application/ogg', |
||
| 48 | 'application/ogg', |
||
| 49 | ['application', null], |
||
| 50 | ['ogg', null], |
||
| 51 | false, |
||
| 52 | [], |
||
| 53 | ], |
||
| 54 | '*/*' => [ |
||
| 55 | '*/*', |
||
| 56 | '*/*', |
||
| 57 | ['*', null], |
||
| 58 | ['*', null], |
||
| 59 | false, |
||
| 60 | [], |
||
| 61 | ], |
||
| 62 | 'n/n' => [ |
||
| 63 | 'n/n', |
||
| 64 | 'n/n', |
||
| 65 | ['n', null], |
||
| 66 | ['n', null], |
||
| 67 | false, |
||
| 68 | [], |
||
| 69 | ], |
||
| 70 | '(UTF-8 Plain Text) text / plain ; charset = utf-8' => [ |
||
| 71 | '(UTF-8 Plain Text) text / plain ; charset = utf-8', |
||
| 72 | 'text/plain; charset="utf-8"', |
||
| 73 | ['text', 'UTF-8 Plain Text'], |
||
| 74 | ['plain', null], |
||
| 75 | true, |
||
| 76 | [ |
||
| 77 | 'charset' => ['utf-8', null], |
||
| 78 | ], |
||
| 79 | ], |
||
| 80 | 'text (Text) / plain ; charset = utf-8' => [ |
||
| 81 | 'text (Text) / plain ; charset = utf-8', |
||
| 82 | 'text/plain; charset="utf-8"', |
||
| 83 | ['text', 'Text'], |
||
| 84 | ['plain', null], |
||
| 85 | true, |
||
| 86 | [ |
||
| 87 | 'charset' => ['utf-8', null], |
||
| 88 | ], |
||
| 89 | ], |
||
| 90 | 'text / (Plain) plain ; charset = utf-8' => [ |
||
| 91 | 'text / (Plain) plain ; charset = utf-8', |
||
| 92 | 'text/plain; charset="utf-8"', |
||
| 93 | ['text', null], |
||
| 94 | ['plain', 'Plain'], |
||
| 95 | true, |
||
| 96 | [ |
||
| 97 | 'charset' => ['utf-8', null], |
||
| 98 | ], |
||
| 99 | ], |
||
| 100 | 'text / plain (Plain Text) ; charset = utf-8' => [ |
||
| 101 | 'text / plain (Plain Text) ; charset = utf-8', |
||
| 102 | 'text/plain; charset="utf-8"', |
||
| 103 | ['text', null], |
||
| 104 | ['plain', 'Plain Text'], |
||
| 105 | true, |
||
| 106 | [ |
||
| 107 | 'charset' => ['utf-8', null], |
||
| 108 | ], |
||
| 109 | ], |
||
| 110 | 'text / plain ; (Charset=utf-8) charset = utf-8' => [ |
||
| 111 | 'text / plain ; (Charset=utf-8) charset = utf-8', |
||
| 112 | 'text/plain; charset="utf-8" (Charset=utf-8)', |
||
| 113 | ['text', null], |
||
| 114 | ['plain', null], |
||
| 115 | true, |
||
| 116 | [ |
||
| 117 | 'charset' => ['utf-8', 'Charset=utf-8'], |
||
| 118 | ], |
||
| 119 | ], |
||
| 120 | 'text / plain ; charset (Charset) = utf-8' => [ |
||
| 121 | 'text / plain ; charset (Charset) = utf-8', |
||
| 122 | 'text/plain; charset="utf-8" (Charset)', |
||
| 123 | ['text', null], |
||
| 124 | ['plain', null], |
||
| 125 | true, |
||
| 126 | [ |
||
| 127 | 'charset' => ['utf-8', 'Charset'], |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | 'text / plain ; charset = (UTF8) utf-8' => [ |
||
| 131 | 'text / plain ; charset = (UTF8) utf-8', |
||
| 132 | 'text/plain; charset="utf-8" (UTF8)', |
||
| 133 | ['text', null], |
||
| 134 | ['plain', null], |
||
| 135 | true, |
||
| 136 | [ |
||
| 137 | 'charset' => ['utf-8', 'UTF8'], |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | 'text / plain ; charset = utf-8 (UTF-8 Plain Text)' => [ |
||
| 141 | 'text / plain ; charset = utf-8 (UTF-8 Plain Text)', |
||
| 142 | 'text/plain; charset="utf-8" (UTF-8 Plain Text)', |
||
| 143 | ['text', null], |
||
| 144 | ['plain', null], |
||
| 145 | true, |
||
| 146 | [ |
||
| 147 | 'charset' => ['utf-8', 'UTF-8 Plain Text'], |
||
| 148 | ], |
||
| 149 | ], |
||
| 150 | 'application/x-foobar;description="bbgh(kdur"' => [ |
||
| 151 | 'application/x-foobar;description="bbgh(kdur"', |
||
| 152 | 'application/x-foobar; description="bbgh(kdur"', |
||
| 153 | ['application', null], |
||
| 154 | ['x-foobar', null], |
||
| 155 | true, |
||
| 156 | [ |
||
| 157 | 'description' => ['bbgh(kdur', null], |
||
| 158 | ], |
||
| 159 | ], |
||
| 160 | 'application/x-foobar;description="a \"quoted string\""' => [ |
||
| 161 | 'application/x-foobar;description="a \"quoted string\""', |
||
| 162 | 'application/x-foobar; description="a \"quoted string\""', |
||
| 163 | ['application', null], |
||
| 164 | ['x-foobar', null], |
||
| 165 | true, |
||
| 166 | [ |
||
| 167 | 'description' => ['a "quoted string"', null], |
||
| 168 | ], |
||
| 169 | ], |
||
| 170 | 'text/xml;description=test' => [ |
||
| 171 | 'text/xml;description=test', |
||
| 172 | 'text/xml; description="test"', |
||
| 173 | ['text', null], |
||
| 174 | ['xml', null], |
||
| 175 | true, |
||
| 176 | [ |
||
| 177 | 'description' => ['test', null], |
||
| 178 | ], |
||
| 179 | ], |
||
| 180 | 'text/xml;one=test;two=three' => [ |
||
| 181 | 'text/xml;one=test;two=three', |
||
| 182 | 'text/xml; one="test"; two="three"', |
||
| 183 | ['text', null], |
||
| 184 | ['xml', null], |
||
| 185 | true, |
||
| 186 | [ |
||
| 187 | 'one' => ['test', null], |
||
| 188 | 'two' => ['three', null], |
||
| 189 | ], |
||
| 190 | ], |
||
| 191 | 'text/xml; this="is"; a="parameter" (with a comment)' => [ |
||
| 192 | 'text/xml; this="is"; a="parameter" (with a comment)', |
||
| 193 | 'text/xml; this="is"; a="parameter" (with a comment)', |
||
| 194 | ['text', null], |
||
| 195 | ['xml', null], |
||
| 196 | true, |
||
| 197 | [ |
||
| 198 | 'this' => ['is', null], |
||
| 199 | 'a' => ['parameter', 'with a comment'], |
||
| 200 | ], |
||
| 201 | ], |
||
| 202 | // Various edge cases. |
||
| 203 | 'text/plain; charset="utf-8" (UTF/8)' => [ |
||
| 204 | 'text/plain; charset="utf-8" (UTF/8)', |
||
| 205 | 'text/plain; charset="utf-8" (UTF/8)', |
||
| 206 | ['text', null], |
||
| 207 | ['plain', null], |
||
| 208 | true, |
||
| 209 | [ |
||
| 210 | 'charset' => ['utf-8', 'UTF/8'], |
||
| 211 | ], |
||
| 212 | ], |
||
| 213 | 'appf/xml; a=b; b="parameter" (with; a comment) ;c=d; e=f (;) ; g=h ' => [ |
||
| 214 | 'appf/xml; a=b; b="parameter" (with; a comment) ;c=d; e=f (;) ; g=h ', |
||
| 215 | 'appf/xml; a="b"; b="parameter" (with; a comment); c="d"; e="f" (;); g="h"', |
||
| 216 | ['appf', null], |
||
| 217 | ['xml', null], |
||
| 218 | true, |
||
| 219 | [ |
||
| 220 | 'a' => ['b', null], |
||
| 221 | 'b' => ['parameter', 'with; a comment'], |
||
| 222 | 'c' => ['d', null], |
||
| 223 | 'e' => ['f', ';'], |
||
| 224 | 'g' => ['h', null], |
||
| 225 | ], |
||
| 226 | ], |
||
| 227 | 'text/(abc)def(ghi)' => [ |
||
| 228 | 'text/(abc)def(ghi)', |
||
| 229 | 'text/def', |
||
| 230 | ['text', null], |
||
| 231 | ['def', 'abc ghi'], |
||
| 232 | false, |
||
| 233 | [], |
||
| 234 | ], |
||
| 235 | 'text/(abc)def' => [ |
||
| 236 | 'text/(abc)def', |
||
| 237 | 'text/def', |
||
| 238 | ['text', null], |
||
| 239 | ['def', 'abc'], |
||
| 240 | false, |
||
| 241 | [], |
||
| 242 | ], |
||
| 243 | 'text/def(ghi)' => [ |
||
| 244 | 'text/def(ghi)', |
||
| 245 | 'text/def', |
||
| 246 | ['text', null], |
||
| 247 | ['def', 'ghi'], |
||
| 248 | false, |
||
| 249 | [], |
||
| 250 | ], |
||
| 251 | 'text/plain;a=(\)abc)def(\()' => [ |
||
| 252 | 'text/plain;a=(\)abc)def(\()', |
||
| 253 | 'text/plain; a="def" (\)abc \()', |
||
| 254 | ['text', null], |
||
| 255 | ['plain', null], |
||
| 256 | true, |
||
| 257 | [ |
||
| 258 | 'a' => ['def', '\)abc \('], |
||
| 259 | ], |
||
| 260 | ], |
||
| 261 | 'text/plain;a=\\foo(abc)' => [ |
||
| 262 | 'text/plain;a=\\foo(abc)', |
||
| 263 | 'text/plain; a="foo" (abc)', |
||
| 264 | ['text', null], |
||
| 265 | ['plain', null], |
||
| 266 | true, |
||
| 267 | [ |
||
| 268 | 'a' => ['foo', 'abc'], |
||
| 269 | ], |
||
| 270 | ], |
||
| 271 | 'text/plain;a=(a"bc\)def")def' => [ |
||
| 272 | 'text/plain;a=(a"bc\)def")def', |
||
| 273 | 'text/plain; a="def" (a"bc\)def")', |
||
| 274 | ['text', null], |
||
| 275 | ['plain', null], |
||
| 276 | true, |
||
| 277 | [ |
||
| 278 | 'a' => ['def', 'a"bc\)def"'], |
||
| 279 | ], |
||
| 280 | ], |
||
| 281 | 'text/plain;a="(abc)def"' => [ |
||
| 282 | 'text/plain;a="(abc)def"', |
||
| 283 | 'text/plain; a="(abc)def"', |
||
| 284 | ['text', null], |
||
| 285 | ['plain', null], |
||
| 286 | true, |
||
| 287 | [ |
||
| 288 | 'a' => ['(abc)def', null], |
||
| 289 | ], |
||
| 290 | ], |
||
| 291 | ]; |
||
| 292 | } |
||
| 293 | |||
| 433 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: