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

CacheContextsCollector::getVisitor()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 1
nop 2
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
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
}