| Conditions | 7 |
| Paths | 8 |
| Total Lines | 27 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 7.392 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 1 | public static function schemaDefinitionNotAloneMessage() |
|
| 20 | { |
||
| 21 | 1 | return 'Must provide only one schema definition.'; |
|
| 22 | } |
||
| 23 | |||
| 24 | 2 | public static function canNotDefineSchemaWithinExtensionMessage() |
|
| 25 | { |
||
| 26 | 2 | return 'Cannot define a new schema within a schema extension.'; |
|
| 27 | } |
||
| 28 | |||
| 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)); |
|
| 60 |