ResponseCode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 5
c 0
b 0
f 0
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 6 3
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Routing\Response;
4
5
use Drupal\graphql\GraphQL\Execution\ResolveContext;
6
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
7
use Psr\Http\Message\ResponseInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\HttpFoundation\Response;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use GraphQL\Type\Definition\ResolveInfo;
10
11
/**
12
 * Get the response code of an internal or external request.
13
 *
14
 * @GraphQLField(
15
 *   id = "response_code",
16
 *   secure = true,
17
 *   name = "code",
18
 *   type = "Int",
19
 *   parents = {"InternalResponse", "ExternalResponse"}
20
 * )
21
 */
22
class ResponseCode extends FieldPluginBase {
23
24
  /**
25
   * {@inheritdoc}
26
   */
27
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
28
    if ($value instanceof Response) {
29
      yield $value->getStatusCode();
30
    }
31
    else if ($value instanceof ResponseInterface) {
32
      yield $value->getStatusCode();
33
    }
34
  }
35
36
}
37