| Conditions | 4 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function enterNode(NodeInterface $node): ?NodeInterface |
||
| 27 | { |
||
| 28 | if ($node instanceof OperationDefinitionNode) { |
||
| 29 | // Fragments cannot be defined inside operation definitions. |
||
| 30 | return null; |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($node instanceof FragmentDefinitionNode) { |
||
| 34 | $fragmentName = $node->getNameValue(); |
||
| 35 | |||
| 36 | if (isset($this->knownFragmentNames[$fragmentName])) { |
||
| 37 | $this->validationContext->reportError( |
||
| 38 | new ValidationException( |
||
| 39 | duplicateFragmentMessage($fragmentName), |
||
| 40 | [$this->knownFragmentNames[$fragmentName], $node->getName()] |
||
| 41 | ) |
||
| 42 | ); |
||
| 43 | } else { |
||
| 44 | $this->knownFragmentNames[$fragmentName] = $node->getName(); |
||
| 45 | } |
||
| 46 | |||
| 47 | return null; |
||
| 48 | } |
||
| 49 | |||
| 50 | return $node; |
||
| 51 | } |
||
| 53 |