Completed
Pull Request — 8.x-3.x (#509)
by Sebastian
03:36 queued 01:04
created

ResponseHeader::resolveValues()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 3
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Routing\Response;
4
5
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
6
use Psr\Http\Message\ResponseInterface;
7
use Symfony\Component\HttpFoundation\Response;
8
use Youshido\GraphQL\Execution\ResolveInfo;
9
10
/**
11
 * Get the a specific response header of an internal or external request.
12
 *
13
 * @GraphQLField(
14
 *   id = "response_header",
15
 *   secure = true,
16
 *   name = "header",
17
 *   type = "String",
18
 *   parents = {"InternalResponse", "ExternalResponse"},
19
 *   arguments={
20
 *     "key" = "String"
21
 *   }
22
 * )
23
 */
24
class ResponseHeader extends FieldPluginBase {
0 ignored issues
show
Bug introduced by
There is one abstract method getPluginDefinition in this class; you could implement it, or declare this class as abstract.
Loading history...
25
26
  /**
27
   * {@inheritdoc}
28
   */
29
  protected function resolveValues($value, array $args, ResolveInfo $info) {
30
    if ($value instanceof Response) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\HttpFoundation\Response does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
31
      yield $value->headers->get($args['key']);
32
    }
33
    else if ($value instanceof ResponseInterface) {
0 ignored issues
show
Bug introduced by
The class Psr\Http\Message\ResponseInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
34
      yield implode(";", $value->getHeader($args['key']));
35
    }
36
  }
37
38
}
39