function UriRetriever::loadSchema
Fetch a schema from the given URI, json-decode it and return it. Caches schema objects.
Parameters
string $fetchUri Absolute URI:
Return value
object JSON schema object
1 call to UriRetriever::loadSchema()
- UriRetriever::retrieve in vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Uri/ UriRetriever.php - Retrieve a URI
File
-
vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Uri/ UriRetriever.php, line 201
Class
- UriRetriever
- Retrieves JSON Schema URIs
Namespace
JsonSchema\UriCode
protected function loadSchema($fetchUri) {
if (isset($this->schemaCache[$fetchUri])) {
return $this->schemaCache[$fetchUri];
}
$uriRetriever = $this->getUriRetriever();
$contents = $this->uriRetriever
->retrieve($fetchUri);
$this->confirmMediaType($uriRetriever, $fetchUri);
$jsonSchema = json_decode($contents);
if (JSON_ERROR_NONE < ($error = json_last_error())) {
throw new JsonDecodingException($error);
}
$this->schemaCache[$fetchUri] = $jsonSchema;
return $jsonSchema;
}