UriRetriever
in package
implements
UriRetrieverInterface
Retrieves JSON Schema URIs
Tags
Table of Contents
Interfaces
Properties
- $allowedInvalidContentTypeEndpoints : array<string|int, mixed>
- $translationMap : array<string|int, mixed>
- $uriRetriever : null|UriRetrieverInterface
- $schemaCache : array<string|int, mixed>|array<string|int, object>
Methods
- addInvalidContentTypeEndpoint() : mixed
- Adds an endpoint to the media type validation exclusion list
- confirmMediaType() : bool|void
- Guarantee the correct media type was encountered
- generate() : string
- Builds a URI based on n array with the main components
- getUriRetriever() : UriRetrieverInterface
- Get a URI Retriever
- isValid() : bool
- parse() : array<string|int, mixed>
- Parses a URI into five main components
- resolve() : string
- Resolves a URI
- resolvePointer() : object
- Resolve a schema based on pointer
- retrieve() : object
- Retrieve a URI
- setTranslation() : mixed
- Set a URL translation rule
- setUriRetriever() : $this
- Set the URI Retriever
- translate() : mixed
- Apply URI translation rules
- loadSchema() : object
- Fetch a schema from the given URI, json-decode it and return it.
Properties
$allowedInvalidContentTypeEndpoints
protected
array<string|int, mixed>
$allowedInvalidContentTypeEndpoints
= array('http://json-schema.org/', 'https://json-schema.org/')
A list of endpoints for media type check exclusion
$translationMap
protected
array<string|int, mixed>
$translationMap
= array(
// use local copies of the spec schemas
'|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json',
)
Map of URL translations
$uriRetriever
protected
null|UriRetrieverInterface
$uriRetriever
= null
$schemaCache
private
array<string|int, mixed>|array<string|int, object>
$schemaCache
= array()
Tags
Methods
addInvalidContentTypeEndpoint()
Adds an endpoint to the media type validation exclusion list
public
addInvalidContentTypeEndpoint(string $endpoint) : mixed
Parameters
- $endpoint : string
confirmMediaType()
Guarantee the correct media type was encountered
public
confirmMediaType(UriRetrieverInterface $uriRetriever, string $uri) : bool|void
Parameters
- $uriRetriever : UriRetrieverInterface
- $uri : string
Return values
bool|voidgenerate()
Builds a URI based on n array with the main components
public
generate(array<string|int, mixed> $components) : string
Parameters
- $components : array<string|int, mixed>
Return values
stringgetUriRetriever()
Get a URI Retriever
public
getUriRetriever() : UriRetrieverInterface
If none is specified, sets a default FileGetContents retriever and returns that object.
Return values
UriRetrieverInterfaceisValid()
public
isValid(string $uri) : bool
Parameters
- $uri : string
Return values
boolparse()
Parses a URI into five main components
public
parse(string $uri) : array<string|int, mixed>
Parameters
- $uri : string
Return values
array<string|int, mixed>resolve()
Resolves a URI
public
resolve(string $uri[, string $baseUri = null ]) : string
Parameters
- $uri : string
-
Absolute or relative
- $baseUri : string = null
-
Optional base URI
Return values
stringresolvePointer()
Resolve a schema based on pointer
public
resolvePointer(object $jsonSchema, string $uri) : object
URIs can have a fragment at the end in the format of #/path/to/object and we are to look up the 'path' property of the first object then the 'to' and 'object' properties.
Parameters
- $jsonSchema : object
-
JSON Schema contents
- $uri : string
-
JSON Schema URI
Tags
Return values
object —JSON Schema after walking down the fragment pieces
retrieve()
Retrieve a URI
public
retrieve(mixed $uri[, mixed $baseUri = null ][, mixed $translate = true ]) : object
Parameters
- $uri : mixed
-
JSON Schema URI
- $baseUri : mixed = null
- $translate : mixed = true
Return values
object —JSON Schema contents
setTranslation()
Set a URL translation rule
public
setTranslation(mixed $from, mixed $to) : mixed
Parameters
- $from : mixed
- $to : mixed
setUriRetriever()
Set the URI Retriever
public
setUriRetriever(UriRetrieverInterface $uriRetriever) : $this
Parameters
- $uriRetriever : UriRetrieverInterface
Return values
$this —for chaining
translate()
Apply URI translation rules
public
translate(mixed $uri) : mixed
Parameters
- $uri : mixed
loadSchema()
Fetch a schema from the given URI, json-decode it and return it.
protected
loadSchema(string $fetchUri) : object
Caches schema objects.
Parameters
- $fetchUri : string
-
Absolute URI
Return values
object —JSON schema object