| Conditions | 1 |
| Paths | 1 |
| Total Lines | 89 |
| Code Lines | 50 |
| 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 |
||
| 35 | public function invalidRequestProvider() |
||
| 36 | { |
||
| 37 | $variable1 = (new Variable('test', 'Int'))->setUsed(true); |
||
| 38 | $variable2 = (new Variable('test2', 'Int'))->setUsed(true); |
||
| 39 | $variable3 = (new Variable('test3', 'Int'))->setUsed(false); |
||
| 40 | |||
| 41 | return [ |
||
| 42 | [ |
||
| 43 | new Request([ |
||
| 44 | 'queries' => [ |
||
| 45 | new Query('test', null, [], [ |
||
| 46 | new FragmentReference('reference') |
||
| 47 | ]) |
||
| 48 | ], |
||
| 49 | 'fragmentReferences' => [ |
||
| 50 | new FragmentReference('reference') |
||
| 51 | ] |
||
| 52 | ]) |
||
| 53 | ], |
||
| 54 | [ |
||
| 55 | new Request([ |
||
| 56 | 'queries' => [ |
||
| 57 | new Query('test', null, [], [ |
||
| 58 | new FragmentReference('reference'), |
||
| 59 | new FragmentReference('reference2'), |
||
| 60 | ]) |
||
| 61 | ], |
||
| 62 | 'fragments' => [ |
||
| 63 | new Fragment('reference', 'TestType', []) |
||
| 64 | ], |
||
| 65 | 'fragmentReferences' => [ |
||
| 66 | new FragmentReference('reference'), |
||
| 67 | new FragmentReference('reference2') |
||
| 68 | ] |
||
| 69 | ]) |
||
| 70 | ], |
||
| 71 | [ |
||
| 72 | new Request([ |
||
| 73 | 'queries' => [ |
||
| 74 | new Query('test', null, [], [ |
||
| 75 | new FragmentReference('reference'), |
||
| 76 | ]) |
||
| 77 | ], |
||
| 78 | 'fragments' => [ |
||
| 79 | new Fragment('reference', 'TestType', []), |
||
| 80 | new Fragment('reference2', 'TestType', []) |
||
| 81 | ], |
||
| 82 | 'fragmentReferences' => [ |
||
| 83 | new FragmentReference('reference') |
||
| 84 | ] |
||
| 85 | ]) |
||
| 86 | ], |
||
| 87 | [ |
||
| 88 | new Request([ |
||
| 89 | 'queries' => [ |
||
| 90 | new Query('test', null, [ |
||
| 91 | new Argument('test', new VariableReference('test')) |
||
| 92 | ], [ |
||
| 93 | new Field('test') |
||
| 94 | ]) |
||
| 95 | ], |
||
| 96 | 'variableReferences' => [ |
||
| 97 | new VariableReference('test') |
||
| 98 | ] |
||
| 99 | ]) |
||
| 100 | ], |
||
| 101 | [ |
||
| 102 | new Request([ |
||
| 103 | 'queries' => [ |
||
| 104 | new Query('test', null, [ |
||
| 105 | new Argument('test', new VariableReference('test', $variable1)), |
||
| 106 | new Argument('test2', new VariableReference('test2', $variable2)), |
||
| 107 | ], [ |
||
| 108 | new Field('test') |
||
| 109 | ]) |
||
| 110 | ], |
||
| 111 | 'variables' => [ |
||
| 112 | $variable1, |
||
| 113 | $variable2, |
||
| 114 | $variable3 |
||
| 115 | ], |
||
| 116 | 'variableReferences' => [ |
||
| 117 | new VariableReference('test', $variable1), |
||
| 118 | new VariableReference('test2', $variable2) |
||
| 119 | ] |
||
| 120 | ]) |
||
| 121 | ] |
||
| 122 | ]; |
||
| 123 | } |
||
| 124 | |||
| 125 | } |