| Conditions | 7 |
| Paths | 8 |
| Total Lines | 27 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | 210 | public function getSDLVisitor(SDLValidationContext $context) |
|
| 30 | { |
||
| 31 | 210 | $oldSchema = $context->getSchema(); |
|
| 32 | 210 | $alreadyDefined = $oldSchema !== null |
|
| 33 | ? ( |
||
| 34 | 68 | $oldSchema->getAstNode() || |
|
| 35 | 67 | $oldSchema->getQueryType() || |
|
| 36 | 3 | $oldSchema->getMutationType() || |
|
| 37 | 68 | $oldSchema->getSubscriptionType() |
|
| 38 | ) |
||
| 39 | 210 | : false; |
|
| 40 | |||
| 41 | 210 | $schemaDefinitionsCount = 0; |
|
| 42 | |||
| 43 | return [ |
||
| 44 | NodeKind::SCHEMA_DEFINITION => static function (SchemaDefinitionNode $node) use ($alreadyDefined, $context, &$schemaDefinitionsCount) { |
||
| 45 | 34 | if ($alreadyDefined !== false) { |
|
| 46 | 2 | $context->reportError(new Error(self::canNotDefineSchemaWithinExtensionMessage(), $node)); |
|
| 47 | |||
| 48 | 2 | return; |
|
| 49 | } |
||
| 50 | |||
| 51 | 33 | if ($schemaDefinitionsCount > 0) { |
|
| 52 | 1 | $context->reportError(new Error(self::schemaDefinitionNotAloneMessage(), $node)); |
|
| 53 | } |
||
| 54 | |||
| 55 | 33 | ++$schemaDefinitionsCount; |
|
| 56 | 210 | }, |
|
| 60 |