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