Rules
2 months ago
DocumentValidator.php
2 months ago
QueryValidationContext.php
2 months ago
SDLValidationContext.php
2 months ago
ValidationContext.php
2 months ago
SDLValidationContext.php
44 lines
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Vendor\GraphQL\Validator; |
| 4 | |
| 5 | use Automattic\WooCommerce\Vendor\GraphQL\Error\Error; |
| 6 | use Automattic\WooCommerce\Vendor\GraphQL\Language\AST\DocumentNode; |
| 7 | use Automattic\WooCommerce\Vendor\GraphQL\Type\Schema; |
| 8 | |
| 9 | class SDLValidationContext implements ValidationContext |
| 10 | { |
| 11 | protected DocumentNode $ast; |
| 12 | |
| 13 | protected ?Schema $schema; |
| 14 | |
| 15 | /** @var list<Error> */ |
| 16 | protected array $errors = []; |
| 17 | |
| 18 | public function __construct(DocumentNode $ast, ?Schema $schema) |
| 19 | { |
| 20 | $this->ast = $ast; |
| 21 | $this->schema = $schema; |
| 22 | } |
| 23 | |
| 24 | public function reportError(Error $error): void |
| 25 | { |
| 26 | $this->errors[] = $error; |
| 27 | } |
| 28 | |
| 29 | public function getErrors(): array |
| 30 | { |
| 31 | return $this->errors; |
| 32 | } |
| 33 | |
| 34 | public function getDocument(): DocumentNode |
| 35 | { |
| 36 | return $this->ast; |
| 37 | } |
| 38 | |
| 39 | public function getSchema(): ?Schema |
| 40 | { |
| 41 | return $this->schema; |
| 42 | } |
| 43 | } |
| 44 |