Conditions | 2 |
Paths | 1 |
Total Lines | 28 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
23 | 172 | public function getVisitor(ValidationContext $context) |
|
24 | { |
||
25 | 172 | $this->knownNames = []; |
|
26 | 172 | $this->knownNameStack = []; |
|
27 | |||
28 | return [ |
||
29 | NodeKind::OBJECT => [ |
||
30 | 'enter' => function () { |
||
31 | 6 | $this->knownNameStack[] = $this->knownNames; |
|
32 | 6 | $this->knownNames = []; |
|
33 | 172 | }, |
|
34 | 'leave' => function () { |
||
35 | 6 | $this->knownNames = array_pop($this->knownNameStack); |
|
36 | 172 | }, |
|
37 | ], |
||
38 | NodeKind::OBJECT_FIELD => function (ObjectFieldNode $node) use ($context) { |
||
39 | 6 | $fieldName = $node->name->value; |
|
40 | |||
41 | 6 | if (! empty($this->knownNames[$fieldName])) { |
|
42 | 2 | $context->reportError(new Error( |
|
43 | 2 | self::duplicateInputFieldMessage($fieldName), |
|
44 | 2 | [$this->knownNames[$fieldName], $node->name] |
|
45 | )); |
||
46 | } else { |
||
47 | 6 | $this->knownNames[$fieldName] = $node->name; |
|
48 | } |
||
49 | |||
50 | 6 | return Visitor::skipNode(); |
|
51 | 172 | }, |
|
60 |