Completed
Pull Request — 8.x-3.x (#525)
by Sebastian
02:17
created

CacheContextsCollector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getVisitor() 0 12 2
1
<?php
2
3
namespace Drupal\graphql\GraphQL\Visitors;
4
5
use GraphQL\Language\AST\FieldNode;
6
use GraphQL\Language\AST\NodeKind;
7
use GraphQL\Utils\TypeInfo;
8
9
class CacheContextsCollector {
10
11
  /**
12
   * {@inheritdoc}
13
   */
14
  public function getVisitor(TypeInfo $info, array &$contexts) {
15
    return [
16
      NodeKind::FIELD => [
17
        'leave' => function (FieldNode $field) use ($info, &$contexts) {
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
          $definition = $info->getFieldDef();
19
          if (!empty($definition->config['contexts'])) {
20
            $contexts = array_unique(array_merge($contexts, $definition->config['contexts']));
21
          }
22
        },
23
      ],
24
    ];
25
  }
26
}