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