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