Conditions | 3 |
Paths | 3 |
Total Lines | 93 |
Code Lines | 63 |
Lines | 0 |
Ratio | 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 |
||
180 | public function orderByPropertyProvider() { |
||
181 | $class = $this->getInstanceClass(); |
||
182 | |||
183 | $id1 = new PropertyId( 'P1' ); |
||
184 | $id2 = new PropertyId( 'P2' ); |
||
185 | $id3 = new PropertyId( 'P3' ); |
||
186 | |||
187 | /** |
||
188 | * List of test data containing snaks to initialize SnakList objects. The first list of |
||
189 | * snaks represents the snak list to be used as test input while the second represents the |
||
190 | * expected result. |
||
191 | * @var array |
||
192 | */ |
||
193 | $rawArguments = array( |
||
194 | 'Default order' => array( |
||
195 | array(), |
||
196 | array(), |
||
197 | ), |
||
198 | 'Unknown id in order' => array( |
||
199 | array(), |
||
200 | array(), |
||
201 | array( 'P1' ) |
||
202 | ), |
||
203 | array( |
||
204 | array( new PropertyNoValueSnak( $id1 ) ), |
||
205 | array( new PropertyNoValueSnak( $id1 ) ), |
||
206 | ), |
||
207 | array( |
||
208 | array( |
||
209 | new PropertyNoValueSnak( $id2 ), |
||
210 | new PropertyNoValueSnak( $id1 ), |
||
211 | ), |
||
212 | array( |
||
213 | new PropertyNoValueSnak( $id2 ), |
||
214 | new PropertyNoValueSnak( $id1 ), |
||
215 | ), |
||
216 | ), |
||
217 | array( |
||
218 | array( |
||
219 | new PropertyNoValueSnak( $id1 ), |
||
220 | new PropertyNoValueSnak( $id2 ), |
||
221 | new PropertyValueSnak( $id1, new StringValue( 'a' ) ), |
||
222 | ), |
||
223 | array( |
||
224 | new PropertyNoValueSnak( $id1 ), |
||
225 | new PropertyValueSnak( $id1, new StringValue( 'a' ) ), |
||
226 | new PropertyNoValueSnak( $id2 ), |
||
227 | ), |
||
228 | ), |
||
229 | 'With additional order' => array( |
||
230 | array( |
||
231 | new PropertyNoValueSnak( $id3 ), |
||
232 | new PropertyNoValueSnak( $id2 ), |
||
233 | new PropertyValueSnak( $id1, new StringValue( 'a' ) ), |
||
234 | ), |
||
235 | array( |
||
236 | new PropertyNoValueSnak( $id2 ), |
||
237 | new PropertyNoValueSnak( $id3 ), |
||
238 | new PropertyValueSnak( $id1, new StringValue( 'a' ) ), |
||
239 | ), |
||
240 | array( 'P2' ) |
||
241 | ), |
||
242 | array( |
||
243 | array( |
||
244 | new PropertyNoValueSnak( $id3 ), |
||
245 | new PropertyNoValueSnak( $id2 ), |
||
246 | new PropertyNoValueSnak( $id2 ), |
||
247 | new PropertyValueSnak( $id1, new StringValue( 'a' ) ), |
||
248 | new PropertyNoValueSnak( $id1 ), |
||
249 | ), |
||
250 | array( |
||
251 | new PropertyValueSnak( $id1, new StringValue( 'a' ) ), |
||
252 | new PropertyNoValueSnak( $id1 ), |
||
253 | new PropertyNoValueSnak( $id3 ), |
||
254 | new PropertyNoValueSnak( $id2 ), |
||
255 | new PropertyNoValueSnak( $id2 ), |
||
256 | ), |
||
257 | array( 'P1' ) |
||
258 | ), |
||
259 | ); |
||
260 | |||
261 | $arguments = array(); |
||
262 | |||
263 | foreach ( $rawArguments as $key => $rawArgument ) { |
||
264 | $arguments[$key] = array( |
||
265 | new $class( $rawArgument[0] ), |
||
266 | new $class( $rawArgument[1] ), |
||
267 | array_key_exists( 2, $rawArgument ) ? $rawArgument[2] : array() |
||
268 | ); |
||
269 | } |
||
270 | |||
271 | return $arguments; |
||
272 | } |
||
273 | |||
296 |