| Conditions | 1 |
| Paths | 1 |
| Total Lines | 173 |
| Code Lines | 87 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 3 | 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 |
||
| 182 | public function queryProvider() |
||
| 183 | { |
||
| 184 | return [ |
||
| 185 | [ |
||
| 186 | 'query CheckTypeOfLuke { |
||
| 187 | hero(episode: EMPIRE) { |
||
| 188 | __typename, |
||
| 189 | name |
||
| 190 | } |
||
| 191 | }', |
||
| 192 | [ |
||
| 193 | 'queries' => [ |
||
| 194 | new Query('hero', null, [ |
||
| 195 | new Argument('episode', new Literal('EMPIRE')) |
||
| 196 | ], [ |
||
| 197 | new Field('__typename'), |
||
| 198 | new Field('name'), |
||
| 199 | ]) |
||
| 200 | ], |
||
| 201 | 'mutations' => [], |
||
| 202 | 'fragments' => [] |
||
| 203 | ] |
||
| 204 | ], |
||
| 205 | [ |
||
| 206 | '{ test { __typename, id } }', |
||
| 207 | [ |
||
| 208 | 'queries' => [ |
||
| 209 | new Query('test', null, [], [ |
||
| 210 | new Field('__typename'), |
||
| 211 | new Field('id'), |
||
| 212 | ]) |
||
| 213 | ], |
||
| 214 | 'mutations' => [], |
||
| 215 | 'fragments' => [] |
||
| 216 | ] |
||
| 217 | ], |
||
| 218 | [ |
||
| 219 | '{}', |
||
| 220 | [ |
||
| 221 | 'queries' => [], |
||
| 222 | 'mutations' => [], |
||
| 223 | 'fragments' => [] |
||
| 224 | ] |
||
| 225 | ], |
||
| 226 | [ |
||
| 227 | 'query test {}', |
||
| 228 | [ |
||
| 229 | 'queries' => [], |
||
| 230 | 'mutations' => [], |
||
| 231 | 'fragments' => [] |
||
| 232 | ] |
||
| 233 | ], |
||
| 234 | [ |
||
| 235 | 'query {}', |
||
| 236 | [ |
||
| 237 | 'queries' => [], |
||
| 238 | 'mutations' => [], |
||
| 239 | 'fragments' => [] |
||
| 240 | ] |
||
| 241 | ], |
||
| 242 | [ |
||
| 243 | 'mutation setName { setUserName }', |
||
| 244 | [ |
||
| 245 | 'queries' => [], |
||
| 246 | 'mutations' => [new Mutation('setUserName')], |
||
| 247 | 'fragments' => [] |
||
| 248 | ] |
||
| 249 | ], |
||
| 250 | [ |
||
| 251 | '{ test { ...userDataFragment } } fragment userDataFragment on User { id, name, email }', |
||
| 252 | [ |
||
| 253 | 'queries' => [ |
||
| 254 | new Query('test', null, [], [new FragmentReference('userDataFragment')]) |
||
| 255 | ], |
||
| 256 | 'mutations' => [], |
||
| 257 | 'fragments' => [ |
||
| 258 | new Fragment('userDataFragment', 'User', [ |
||
| 259 | new Field('id'), |
||
| 260 | new Field('name'), |
||
| 261 | new Field('email') |
||
| 262 | ]) |
||
| 263 | ] |
||
| 264 | ] |
||
| 265 | ], |
||
| 266 | [ |
||
| 267 | '{ user (id: 10, name: "max", float: 123.123 ) { id, name } }', |
||
| 268 | [ |
||
| 269 | 'queries' => [ |
||
| 270 | new Query( |
||
| 271 | 'user', |
||
| 272 | null, |
||
| 273 | [ |
||
| 274 | new Argument('id', new Literal('10')), |
||
| 275 | new Argument('name', new Literal('max')), |
||
| 276 | new Argument('float', new Literal('123.123')) |
||
| 277 | ], |
||
| 278 | [ |
||
| 279 | new Field('id'), |
||
| 280 | new Field('name') |
||
| 281 | ] |
||
| 282 | ) |
||
| 283 | ], |
||
| 284 | 'mutations' => [], |
||
| 285 | 'fragments' => [] |
||
| 286 | ] |
||
| 287 | ], |
||
| 288 | [ |
||
| 289 | '{ allUsers : users ( id: [ 1, 2, 3] ) { id } }', |
||
| 290 | [ |
||
| 291 | 'queries' => [ |
||
| 292 | new Query( |
||
| 293 | 'users', |
||
| 294 | 'allUsers', |
||
| 295 | [ |
||
| 296 | new Argument('id', new InputList([1, 2, 3])) |
||
| 297 | ], |
||
| 298 | [ |
||
| 299 | new Field('id') |
||
| 300 | ] |
||
| 301 | ) |
||
| 302 | ], |
||
| 303 | 'mutations' => [], |
||
| 304 | 'fragments' => [] |
||
| 305 | ] |
||
| 306 | ], |
||
| 307 | [ |
||
| 308 | '{ allUsers : users ( id: [ 1, "2", true, null] ) { id } }', |
||
| 309 | [ |
||
| 310 | 'queries' => [ |
||
| 311 | new Query( |
||
| 312 | 'users', |
||
| 313 | 'allUsers', |
||
| 314 | [ |
||
| 315 | new Argument('id', new InputList([1, "2", true, null])) |
||
| 316 | ], |
||
| 317 | [ |
||
| 318 | new Field('id') |
||
| 319 | ] |
||
| 320 | ) |
||
| 321 | ], |
||
| 322 | 'mutations' => [], |
||
| 323 | 'fragments' => [] |
||
| 324 | ] |
||
| 325 | ], |
||
| 326 | [ |
||
| 327 | '{ allUsers : users ( object: { "a": 123, "d": "asd", "b" : [ 1, 2, 4 ], "c": { "a" : 123, "b": "asd" } } ) { id } }', |
||
| 328 | [ |
||
| 329 | 'queries' => [ |
||
| 330 | new Query( |
||
| 331 | 'users', |
||
| 332 | 'allUsers', |
||
| 333 | [ |
||
| 334 | new Argument('object', new InputObject([ |
||
| 335 | 'a' => 123, |
||
| 336 | 'd' => 'asd', |
||
| 337 | 'b' => [1, 2, 4], |
||
| 338 | 'c' => [ |
||
| 339 | 'a' => 123, |
||
| 340 | 'b' => 'asd' |
||
| 341 | ] |
||
| 342 | ])) |
||
| 343 | ], |
||
| 344 | [ |
||
| 345 | new Field('id') |
||
| 346 | ] |
||
| 347 | ) |
||
| 348 | ], |
||
| 349 | 'mutations' => [], |
||
| 350 | 'fragments' => [] |
||
| 351 | ] |
||
| 352 | ] |
||
| 353 | ]; |
||
| 354 | } |
||
| 355 | |||
| 356 | } |