| Conditions | 7 |
| Paths | 8 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 7.392 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 52 | public function getVisitor(ValidationContext $context) |
|
| 20 | { |
||
| 21 | 52 | $oldSchema = $context->getSchema(); |
|
| 22 | 52 | $alreadyDefined = $oldSchema !== null ? ( |
|
| 23 | 52 | $oldSchema->getAstNode() || |
|
| 24 | 52 | $oldSchema->getQueryType() || |
|
| 25 | 1 | $oldSchema->getMutationType() || |
|
| 26 | 52 | $oldSchema->getSubscriptionType() |
|
| 27 | 52 | ) : false; |
|
| 28 | |||
| 29 | 52 | $schemaDefinitionsCount = 0; |
|
| 30 | |||
| 31 | return [ |
||
| 32 | NodeKind::SCHEMA_DEFINITION => static function (SchemaDefinitionNode $node) use ($alreadyDefined, $context, &$schemaDefinitionsCount) { |
||
| 33 | 1 | if ($alreadyDefined !== false) { |
|
| 34 | $context->reportError(new Error('Cannot define a new schema within a schema extension.', $node)); |
||
| 35 | return; |
||
| 36 | } |
||
| 37 | |||
| 38 | 1 | if ($schemaDefinitionsCount > 0) { |
|
| 39 | $context->reportError(new Error('Must provide only one schema definition.', $node)); |
||
| 40 | } |
||
| 41 | |||
| 42 | 1 | ++$schemaDefinitionsCount; |
|
| 43 | 52 | }, |
|
| 47 |