| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | function buildSchema(string $source, array $options = []): SchemaInterface |
||
| 21 | { |
||
| 22 | static $instance = null; |
||
| 23 | |||
| 24 | /** @var DocumentNode $documentNode */ |
||
| 25 | $documentNode = parse($source, $options); |
||
| 26 | |||
| 27 | if (null === $instance) { |
||
| 28 | $resolveType = function (NamedTypeNode $node) { |
||
| 29 | throw new \Exception(sprintf('Type "%s" not found in document.', $node->getNameValue())); |
||
| 30 | }; |
||
| 31 | |||
| 32 | $definitionBuilder = new DefinitionBuilder($resolveType, new RuntimeCache()); |
||
| 33 | $instance = new SchemaBuilder($definitionBuilder); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $instance->build($documentNode, $options); |
||
| 37 | } |
||
| 38 |