| Conditions | 1 |
| Paths | 1 |
| Total Lines | 129 |
| 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 |
||
| 155 | |||
| 156 | $processor = new Processor($schema); |
||
| 157 | |||
| 158 | $processor->processPayload($query); |
||
| 159 | $responseData = $processor->getResponseData(); |
||
| 160 | |||
| 161 | $this->assertEquals($expectedResponse, $responseData); |
||
| 162 | } |
||
| 163 | |||
| 164 | public function predefinedSchemaProvider() |
||
| 165 | { |
||
| 166 | return [ |
||
| 167 | [ |
||
| 168 | '{ __type { name } }', |
||
| 169 | [ |
||
| 170 | 'data' => ['__type' => null], |
||
| 171 | 'errors' => [['message' => 'Require "name" arguments to query "__type"']], |
||
| 172 | ], |
||
| 173 | ], |
||
| 174 | [ |
||
| 175 | '{ __type (name: "__Type") { name } }', |
||
| 176 | [ |
||
| 177 | 'data' => [ |
||
| 178 | '__type' => ['name' => '__Type'], |
||
| 179 | ], |
||
| 180 | ], |
||
| 181 | ], |
||
| 182 | [ |
||
| 183 | '{ __type (name: "InvalidName") { name } }', |
||
| 184 | [ |
||
| 185 | 'data' => [ |
||
| 186 | '__type' => null, |
||
| 187 | ], |
||
| 188 | ], |
||
| 189 | ], |
||
| 190 | [ |
||
| 191 | '{ |
||
| 192 | __schema { |
||
| 193 | types { |
||
| 194 | name, |
||
| 195 | fields (includeDeprecated: true) { |
||
| 196 | name |
||
| 197 | args { |
||
| 198 | defaultValue |
||
| 199 | } |
||
| 200 | } |
||
| 201 | } |
||
| 202 | } |
||
| 203 | }', |
||
| 204 | [ |
||
| 205 | 'data' => [ |
||
| 206 | '__schema' => [ |
||
| 207 | 'types' => [ |
||
| 208 | ['name' => 'TestSchemaQuery', 'fields' => [['name' => 'latest', 'args' => [['defaultValue' => 'test'], ['defaultValue' => null]]]]], |
||
| 209 | ['name' => 'Int', 'fields' => null], |
||
| 210 | ['name' => 'LatestType', 'fields' => [['name' => 'id', 'args' => []], ['name' => 'name', 'args' => []]]], |
||
| 211 | ['name' => 'String', 'fields' => null], |
||
| 212 | ['name' => '__Schema', 'fields' => [['name' => 'queryType', 'args' => []], ['name' => 'mutationType', 'args' => []], ['name' => 'subscriptionType', 'args' => []], ['name' => 'types', 'args' => []], ['name' => 'directives', 'args' => []]]], |
||
| 213 | ['name' => '__Type', 'fields' => [['name' => 'name', 'args' => []], ['name' => 'kind', 'args' => []], ['name' => 'description', 'args' => []], ['name' => 'ofType', 'args' => []], ['name' => 'inputFields', 'args' => []], ['name' => 'enumValues', 'args' => [['defaultValue' => 'false']]], ['name' => 'fields', 'args' => [['defaultValue' => 'false']]], ['name' => 'interfaces', 'args' => []], ['name' => 'possibleTypes', 'args' => []]]], |
||
| 214 | ['name' => '__InputValue', 'fields' => [['name' => 'name', 'args' => []], ['name' => 'description', 'args' => []], ['name' => 'isDeprecated', 'args' => []], ['name' => 'deprecationReason', 'args' => []], ['name' => 'type', 'args' => []], ['name' => 'defaultValue', 'args' => []]]], |
||
| 215 | ['name' => 'Boolean', 'fields' => null], |
||
| 216 | ['name' => '__EnumValue', 'fields' => [['name' => 'name', 'args' => []], ['name' => 'description', 'args' => []], ['name' => 'deprecationReason', 'args' => []], ['name' => 'isDeprecated', 'args' => []]]], |
||
| 217 | ['name' => '__Field', 'fields' => [['name' => 'name', 'args' => []], ['name' => 'description', 'args' => []], ['name' => 'isDeprecated', 'args' => []], ['name' => 'deprecationReason', 'args' => []], ['name' => 'type', 'args' => []], ['name' => 'args', 'args' => []]]], |
||
| 218 | ['name' => '__Directive', 'fields' => [['name' => 'name', 'args' => []], ['name' => 'description', 'args' => []], ['name' => 'args', 'args' => []], ['name' => 'locations', 'args' => []]]], |
||
| 219 | ['name' => '__DirectiveLocation', 'fields' => null], |
||
| 220 | ], |
||
| 221 | ], |
||
| 222 | ], |
||
| 223 | ], |
||
| 224 | ], |
||
| 225 | [ |
||
| 226 | '{ |
||
| 227 | test : __schema { |
||
| 228 | queryType { |
||
| 229 | kind, |
||
| 230 | name, |
||
| 231 | fields (includeDeprecated: true) { |
||
| 232 | name, |
||
| 233 | isDeprecated, |
||
| 234 | deprecationReason, |
||
| 235 | description, |
||
| 236 | type { |
||
| 237 | name |
||
| 238 | } |
||
| 239 | } |
||
| 240 | } |
||
| 241 | } |
||
| 242 | }', |
||
| 243 | ['data' => [ |
||
| 244 | 'test' => [ |
||
| 245 | 'queryType' => [ |
||
| 246 | 'name' => 'TestSchemaQuery', |
||
| 247 | 'kind' => 'OBJECT', |
||
| 248 | 'fields' => [ |
||
| 249 | ['name' => 'latest', 'isDeprecated' => true, 'deprecationReason' => 'for test', 'description' => 'latest description', 'type' => ['name' => 'LatestType']], |
||
| 250 | ], |
||
| 251 | ], |
||
| 252 | ], |
||
| 253 | ]], |
||
| 254 | ], |
||
| 255 | [ |
||
| 256 | '{ |
||
| 257 | __schema { |
||
| 258 | queryType { |
||
| 259 | kind, |
||
| 260 | name, |
||
| 261 | description, |
||
| 262 | interfaces { |
||
| 263 | name |
||
| 264 | }, |
||
| 265 | possibleTypes { |
||
| 266 | name |
||
| 267 | }, |
||
| 268 | inputFields { |
||
| 269 | name |
||
| 270 | }, |
||
| 271 | ofType{ |
||
| 272 | name |
||
| 273 | } |
||
| 274 | } |
||
| 275 | } |
||
| 276 | }', |
||
| 277 | ['data' => [ |
||
| 278 | '__schema' => [ |
||
| 279 | 'queryType' => [ |
||
| 280 | 'kind' => 'OBJECT', |
||
| 281 | 'name' => 'TestSchemaQuery', |
||
| 282 | 'description' => null, |
||
| 283 | 'interfaces' => [], |
||
| 284 | 'possibleTypes' => null, |
||
| 380 |