| Conditions | 1 |
| Paths | 1 |
| Total Lines | 116 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 2 | 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 |
||
| 150 | public function queryProvider() |
||
| 151 | { |
||
| 152 | return [ |
||
| 153 | [ |
||
| 154 | '{}', |
||
| 155 | [ |
||
| 156 | 'queries' => [], |
||
| 157 | 'mutations' => [], |
||
| 158 | 'fragments' => [] |
||
| 159 | ] |
||
| 160 | ], |
||
| 161 | [ |
||
| 162 | '{ test { ...userDataFragment } } fragment userDataFragment on User { id, name, email }', |
||
| 163 | [ |
||
| 164 | 'queries' => [ |
||
| 165 | new Query('test', null, [], [new FragmentReference('userDataFragment')]) |
||
| 166 | ], |
||
| 167 | 'mutations' => [], |
||
| 168 | 'fragments' => [ |
||
| 169 | new Fragment('userDataFragment', 'User', [ |
||
| 170 | new Field('id'), |
||
| 171 | new Field('name'), |
||
| 172 | new Field('email') |
||
| 173 | ]) |
||
| 174 | ] |
||
| 175 | ] |
||
| 176 | ], |
||
| 177 | [ |
||
| 178 | '{ user (id: 10, name: "max", float: 123.123 ) { id, name } }', |
||
| 179 | [ |
||
| 180 | 'queries' => [ |
||
| 181 | new Query( |
||
| 182 | 'user', |
||
| 183 | null, |
||
| 184 | [ |
||
| 185 | new Argument('id', new Literal('10')), |
||
| 186 | new Argument('name', new Literal('max')), |
||
| 187 | new Argument('float', new Literal('123.123')) |
||
| 188 | ], |
||
| 189 | [ |
||
| 190 | new Field('id'), |
||
| 191 | new Field('name') |
||
| 192 | ] |
||
| 193 | ) |
||
| 194 | ], |
||
| 195 | 'mutations' => [], |
||
| 196 | 'fragments' => [] |
||
| 197 | ] |
||
| 198 | ], |
||
| 199 | [ |
||
| 200 | '{ allUsers : users ( id: [ 1, 2, 3] ) { id } }', |
||
| 201 | [ |
||
| 202 | 'queries' => [ |
||
| 203 | new Query( |
||
| 204 | 'users', |
||
| 205 | 'allUsers', |
||
| 206 | [ |
||
| 207 | new Argument('id', new InputList([1, 2, 3])) |
||
| 208 | ], |
||
| 209 | [ |
||
| 210 | new Field('id') |
||
| 211 | ] |
||
| 212 | ) |
||
| 213 | ], |
||
| 214 | 'mutations' => [], |
||
| 215 | 'fragments' => [] |
||
| 216 | ] |
||
| 217 | ], |
||
| 218 | [ |
||
| 219 | '{ allUsers : users ( id: [ 1, "2", true, null] ) { id } }', |
||
| 220 | [ |
||
| 221 | 'queries' => [ |
||
| 222 | new Query( |
||
| 223 | 'users', |
||
| 224 | 'allUsers', |
||
| 225 | [ |
||
| 226 | new Argument('id', new InputList([1, "2", true, null])) |
||
| 227 | ], |
||
| 228 | [ |
||
| 229 | new Field('id') |
||
| 230 | ] |
||
| 231 | ) |
||
| 232 | ], |
||
| 233 | 'mutations' => [], |
||
| 234 | 'fragments' => [] |
||
| 235 | ] |
||
| 236 | ], |
||
| 237 | [ |
||
| 238 | '{ allUsers : users ( object: { "a": 123, "d": "asd", "b" : [ 1, 2, 4 ], "c": { "a" : 123, "b": "asd" } } ) { id } }', |
||
| 239 | [ |
||
| 240 | 'queries' => [ |
||
| 241 | new Query( |
||
| 242 | 'users', |
||
| 243 | 'allUsers', |
||
| 244 | [ |
||
| 245 | new Argument('object', new InputObject([ |
||
| 246 | 'a' => 123, |
||
| 247 | 'd' => 'asd', |
||
| 248 | 'b' => [1, 2, 4], |
||
| 249 | 'c' => [ |
||
| 250 | 'a' => 123, |
||
| 251 | 'b' => 'asd' |
||
| 252 | ] |
||
| 253 | ])) |
||
| 254 | ], |
||
| 255 | [ |
||
| 256 | new Field('id') |
||
| 257 | ] |
||
| 258 | ) |
||
| 259 | ], |
||
| 260 | 'mutations' => [], |
||
| 261 | 'fragments' => [] |
||
| 262 | ] |
||
| 263 | ] |
||
| 264 | ]; |
||
| 265 | } |
||
| 266 | |||
| 267 | } |