ResponseHeader   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 a specific response header of an internal or external request.
13
 *
14
 * @GraphQLField(
15
 *   id = "response_header",
16
 *   secure = true,
17
 *   name = "header",
18
 *   type = "String",
19
 *   parents = {"InternalResponse", "ExternalResponse"},
20
 *   arguments={
21
 *     "key" = "String"
22
 *   }
23
 * )
24
 */
25
class ResponseHeader extends FieldPluginBase {
26
27
  /**
28
   * {@inheritdoc}
29
   */
30
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
31
    if ($value instanceof Response) {
32
      yield $value->headers->get($args['key']);
33
    }
34
    else if ($value instanceof ResponseInterface) {
35
      yield implode(";", $value->getHeader($args['key']));
36
    }
37
  }
38
39
}
40