Conditions | 1 |
Paths | 1 |
Total Lines | 163 |
Code Lines | 93 |
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 |
||
56 | public function valueProvider() { |
||
57 | return [ |
||
58 | [ |
||
59 | 'value' => null, |
||
60 | 'options' => [], |
||
61 | 'expectedErrors' => Error::newError( 'Not an array' ) |
||
62 | ], |
||
63 | [ |
||
64 | 'value' => 0, |
||
65 | 'options' => [], |
||
66 | 'expectedErrors' => Error::newError( 'Not an array' ) |
||
67 | ], |
||
68 | [ |
||
69 | 'value' => '', |
||
70 | 'options' => [], |
||
71 | 'expectedErrors' => Error::newError( 'Not an array' ) |
||
72 | ], |
||
73 | [ |
||
74 | 'value' => [], |
||
75 | 'options' => [], |
||
76 | 'expectedErrors' => [] |
||
77 | ], |
||
78 | [ |
||
79 | 'value' => [ 1 ], |
||
80 | 'options' => [], |
||
81 | 'expectedErrors' => [] |
||
82 | ], |
||
83 | |||
84 | // Lower bound only |
||
85 | [ |
||
86 | 'value' => [], |
||
87 | 'options' => [ 'minelements' => null ], |
||
88 | 'expectedErrors' => [] |
||
89 | ], |
||
90 | [ |
||
91 | 'value' => [], |
||
92 | 'options' => [ 'minelements' => 0 ], |
||
93 | 'expectedErrors' => [] |
||
94 | ], |
||
95 | [ |
||
96 | 'value' => [], |
||
97 | 'options' => [ 'minelements' => 1 ], |
||
98 | 'expectedErrors' => Error::newError( 'Value exceeding lower bound', 'length' ) |
||
99 | ], |
||
100 | [ |
||
101 | 'value' => [ 1 ], |
||
102 | 'options' => [ 'minelements' => 1 ], |
||
103 | 'expectedErrors' => [] |
||
104 | ], |
||
105 | |||
106 | // Upper bound only |
||
107 | [ |
||
108 | 'value' => [], |
||
109 | 'options' => [ 'maxelements' => null ], |
||
110 | 'expectedErrors' => [] |
||
111 | ], |
||
112 | [ |
||
113 | 'value' => [], |
||
114 | 'options' => [ 'maxelements' => 0 ], |
||
115 | 'expectedErrors' => [] |
||
116 | ], |
||
117 | [ |
||
118 | 'value' => [ 1 ], |
||
119 | 'options' => [ 'maxelements' => 0 ], |
||
120 | 'expectedErrors' => Error::newError( 'Value exceeding upper bound', 'length' ) |
||
121 | ], |
||
122 | [ |
||
123 | 'value' => [ 1 ], |
||
124 | 'options' => [ 'maxelements' => 1 ], |
||
125 | 'expectedErrors' => [] |
||
126 | ], |
||
127 | |||
128 | // Lower and upper bound |
||
129 | [ |
||
130 | 'value' => [], |
||
131 | 'options' => [ 'elementcount' => [ 0, 0 ] ], |
||
132 | 'expectedErrors' => [] |
||
133 | ], |
||
134 | [ |
||
135 | 'value' => [ 1 ], |
||
136 | 'options' => [ 'elementcount' => [ 2, 2 ] ], |
||
137 | 'expectedErrors' => Error::newError( 'Value exceeding lower bound', 'length' ) |
||
138 | ], |
||
139 | [ |
||
140 | 'value' => [ 1, 2 ], |
||
141 | 'options' => [ 'elementcount' => [ 2, 2 ] ], |
||
142 | 'expectedErrors' => [] |
||
143 | ], |
||
144 | [ |
||
145 | 'value' => [ 1 ], |
||
146 | 'options' => [ 'elementcount' => [ 0, 0 ] ], |
||
147 | 'expectedErrors' => Error::newError( 'Value exceeding upper bound', 'length' ) |
||
148 | ], |
||
149 | [ |
||
150 | 'value' => [], |
||
151 | 'options' => [ 'elementcount' => [ 0, 0 ] ], |
||
152 | 'expectedErrors' => [] |
||
153 | ], |
||
154 | [ |
||
155 | 'value' => [], |
||
156 | 'options' => [ 'elementcount' => [ 2, 0 ] ], |
||
157 | 'expectedErrors' => Error::newError( 'Value exceeding lower bound', 'length' ) |
||
158 | ], |
||
159 | [ |
||
160 | 'value' => [ 1, 2 ], |
||
161 | 'options' => [ 'elementcount' => [ 2, 0 ] ], |
||
162 | 'expectedErrors' => Error::newError( 'Value exceeding upper bound', 'length' ) |
||
163 | ], |
||
164 | [ |
||
165 | 'value' => [ 1 ], |
||
166 | 'options' => [ 'elementcount' => [ 2, 0 ] ], |
||
167 | 'expectedErrors' => [ |
||
168 | Error::newError( 'Value exceeding upper bound', 'length' ), |
||
169 | Error::newError( 'Value exceeding lower bound', 'length' ), |
||
170 | ] |
||
171 | ], |
||
172 | [ |
||
173 | 'value' => [ 1 ], |
||
174 | 'options' => [ 'minelements' => 2, 'maxelements' => 0 ], |
||
175 | 'expectedErrors' => [ |
||
176 | Error::newError( 'Value exceeding upper bound', 'length' ), |
||
177 | Error::newError( 'Value exceeding lower bound', 'length' ), |
||
178 | ] |
||
179 | ], |
||
180 | |||
181 | // Conflicting options |
||
182 | [ |
||
183 | 'value' => [], |
||
184 | 'options' => [ 'elementcount' => [ 1, 1 ], 'minelements' => null ], |
||
185 | 'expectedErrors' => [] |
||
186 | ], |
||
187 | [ |
||
188 | 'value' => [], |
||
189 | 'options' => [ 'elementcount' => [ 1, 1 ], 'minelements' => false ], |
||
190 | 'expectedErrors' => [] |
||
191 | ], |
||
192 | [ |
||
193 | 'value' => [], |
||
194 | 'options' => [ 'elementcount' => [ 1, 1 ], 'minelements' => 0 ], |
||
195 | 'expectedErrors' => [] |
||
196 | ], |
||
197 | [ |
||
198 | 'value' => [], |
||
199 | 'options' => [ 'minelements' => 0, 'elementcount' => [ 1, 1 ] ], |
||
200 | 'expectedErrors' => [] |
||
201 | ], |
||
202 | [ |
||
203 | 'value' => [ 1 ], |
||
204 | 'options' => [ 'elementcount' => [ 0, 0 ], 'maxelements' => false ], |
||
205 | 'expectedErrors' => [] |
||
206 | ], |
||
207 | [ |
||
208 | 'value' => [ 1 ], |
||
209 | 'options' => [ 'elementcount' => [ 0, 0 ], 'maxelements' => 1 ], |
||
210 | 'expectedErrors' => [] |
||
211 | ], |
||
212 | [ |
||
213 | 'value' => [ 1 ], |
||
214 | 'options' => [ 'maxelements' => 1, 'elementcount' => [ 0, 0 ] ], |
||
215 | 'expectedErrors' => [] |
||
216 | ], |
||
217 | ]; |
||
218 | } |
||
219 | |||
221 |