Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
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 |
||
53 | public function dataProvider() |
||
54 | { |
||
55 | $obj = new stdClass(); |
||
56 | $obj->prop1 = "value1"; |
||
57 | $obj->prop2 = "value2"; |
||
58 | |||
59 | return |
||
60 | [ |
||
61 | [ |
||
62 | [ |
||
63 | "text" => "simple string" |
||
64 | ], |
||
65 | "text|s:13:\"simple string\";" |
||
66 | ], |
||
67 | [ |
||
68 | [ |
||
69 | "text" => "simple string", |
||
70 | "text2" => "another string", |
||
71 | "number" => 74 |
||
72 | ], |
||
73 | "text|s:13:\"simple string\";text2|s:14:\"another string\";number|i:74;" |
||
74 | ], |
||
75 | [ |
||
76 | [ |
||
77 | "text" => [ 1, 2, 3 ] |
||
78 | ], |
||
79 | "text|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}" |
||
80 | ], |
||
81 | [ |
||
82 | [ |
||
83 | "text" => [ "a" => 1, "b" => 2, "c" => 3 ] |
||
84 | ], |
||
85 | "text|a:3:{s:1:\"a\";i:1;s:1:\"b\";i:2;s:1:\"c\";i:3;}" |
||
86 | ], |
||
87 | [ |
||
88 | [ |
||
89 | "text" => [ "a" => 1, "b" => 2, "c" => 3 ], |
||
90 | "single" => 2000 |
||
91 | ], |
||
92 | "text|a:3:{s:1:\"a\";i:1;s:1:\"b\";i:2;s:1:\"c\";i:3;}single|i:2000;" |
||
93 | ], |
||
94 | [ |
||
95 | [ |
||
96 | "text" => $obj |
||
97 | ], |
||
98 | "text|O:8:\"stdClass\":2:{s:5:\"prop1\";s:6:\"value1\";s:5:\"prop2\";s:6:\"value2\";}" |
||
99 | ], |
||
100 | [ |
||
101 | [ |
||
102 | "text" => [ "a" => $obj ] |
||
103 | ], |
||
104 | "text|a:1:{s:1:\"a\";O:8:\"stdClass\":2:{s:5:\"prop1\";s:6:\"value1\";s:5:\"prop2\";s:6:\"value2\";}}" |
||
105 | ], |
||
106 | [ |
||
107 | [ |
||
108 | "text" => [ $obj ] |
||
109 | ], |
||
110 | "text|a:1:{i:0;O:8:\"stdClass\":2:{s:5:\"prop1\";s:6:\"value1\";s:5:\"prop2\";s:6:\"value2\";}}" |
||
111 | ] |
||
112 | ]; |
||
113 | } |
||
114 | |||
151 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.