| Total Complexity | 5 | 
| Total Lines | 44 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 2 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php | ||
| 13 | class DocumentValidator | ||
| 14 | { | ||
| 15 | /** | ||
| 16 | * @var stdClass | ||
| 17 | */ | ||
| 18 | protected $jsonSchema; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * @var string | ||
| 22 | */ | ||
| 23 | protected $defaultJsonSchemaFile = '/../Spec/v3/schemas/v3.0.x.yml'; | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @param string $jsonSchema JSON Schema of the Open API specification, in YAML format. If omitted, the bundled | ||
| 27 | * Open API 3.0.x JSON Schema file will be used. | ||
| 28 | */ | ||
| 29 | 12 | public function __construct(string $jsonSchema = null) | |
| 30 |     { | ||
| 31 | 12 |         if (is_null($jsonSchema)) { | |
| 32 | 12 | $schemaFile = realpath(__DIR__ . $this->defaultJsonSchemaFile); | |
| 33 | 12 |             if (!file_exists($schemaFile)) { | |
| 34 | 3 |                 throw new \LogicException("The default schema file cannot be found: ${schemaFile}"); | |
| 35 | } | ||
| 36 | 12 | $jsonSchema = file_get_contents($schemaFile); | |
| 37 | } | ||
| 38 | |||
| 39 | $this->jsonSchema = Yaml::parse($jsonSchema, Yaml::PARSE_OBJECT_FOR_MAP); | ||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * @param Document $document | ||
| 44 | * @return ValidationResult | ||
| 45 | */ | ||
| 46 | public function validate(Document $document): ValidationResult | ||
| 52 | } | ||
| 53 | |||
| 54 | public function getJsonSchema(): stdClass | ||
| 57 | } | ||
| 58 | } | ||
| 59 |