Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 41 |
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 |
||
22 | public function renderProvider(): array |
||
23 | { |
||
24 | $attribs = StubAttributeFactory::createAttributes(); |
||
25 | $str = AttributesHelper::toString($attribs); |
||
26 | |||
27 | return [ |
||
28 | 'simple' => [ |
||
29 | 'abc', |
||
30 | 'bcd', |
||
31 | 'val', |
||
32 | [], |
||
33 | null, |
||
34 | null, |
||
35 | null, |
||
36 | '<select id="abc" name="bcd"></select>', |
||
37 | ], |
||
38 | 'missing translations' => [ |
||
39 | 'abc', |
||
40 | 'bcd', |
||
41 | 'val', |
||
42 | [], |
||
43 | null, |
||
44 | [], |
||
45 | null, |
||
46 | '<select id="abc" name="bcd"></select>', |
||
47 | ], |
||
48 | 'extra attributes' => [ |
||
49 | 'abc', |
||
50 | 'bcd', |
||
51 | 'val', |
||
52 | [], |
||
53 | $attribs, |
||
54 | [], |
||
55 | null, |
||
56 | "<select$str id=\"abc\" name=\"bcd\"></select>", |
||
57 | ], |
||
58 | 'options' => [ |
||
59 | 'abc', |
||
60 | 'bcd', |
||
61 | 'val', |
||
62 | ['bde' => 'BDE', 'cef' => 'CEF'], |
||
63 | $attribs, |
||
64 | [], |
||
65 | null, |
||
66 | "<select$str id=\"abc\" name=\"bcd\"><option value=\"bde\">BDE</option>\n<option value=\"cef\">CEF</option></select>", // phpcs:ignore |
||
67 | ], |
||
68 | 'option selected' => [ |
||
69 | 'abc', |
||
70 | 'bcd', |
||
71 | 'cef', |
||
72 | ['bde' => 'BDE', 'cef' => 'CEF'], |
||
73 | $attribs, |
||
74 | [], |
||
75 | null, |
||
76 | "<select$str id=\"abc\" name=\"bcd\"><option value=\"bde\">BDE</option>\n<option value=\"cef\" selected>CEF</option></select>", // phpcs:ignore |
||
77 | ], |
||
221 |