\JsonSchema\UriUriRetriever

Retrieves JSON Schema URIs

Summary

Methods
Properties
Constants
confirmMediaType()
getUriRetriever()
resolvePointer()
retrieve()
setUriRetriever()
parse()
generate()
resolve()
isValid()
setTranslation()
translate()
No public properties found
No constants found
loadSchema()
$translationMap
$uriRetriever
N/A
No private methods found
$schemaCache
N/A

Properties

$translationMap

$translationMap : array

Type

array — Map of URL translations

$schemaCache

$schemaCache : array|array<mixed,object>

Type

array|array<mixed,object>

Methods

confirmMediaType()

confirmMediaType(\JsonSchema\Uri\Retrievers\UriRetrieverInterface  $uriRetriever, string  $uri) : boolean|void

Guarantee the correct media type was encountered

Parameters

\JsonSchema\Uri\Retrievers\UriRetrieverInterface $uriRetriever
string $uri

Returns

boolean|void

getUriRetriever()

getUriRetriever() : \JsonSchema\Uri\Retrievers\UriRetrieverInterface

Get a URI Retriever

If none is specified, sets a default FileGetContents retriever and returns that object.

Returns

\JsonSchema\Uri\Retrievers\UriRetrieverInterface

resolvePointer()

resolvePointer(object  $jsonSchema, string  $uri) : object

Resolve a schema based on pointer

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

object $jsonSchema

JSON Schema contents

string $uri

JSON Schema URI

Throws

\JsonSchema\Exception\ResourceNotFoundException

Returns

object —

JSON Schema after walking down the fragment pieces

retrieve()

retrieve(string  $uri, null|string  $baseUri = null,   $translate = true) : object

Retrieve a URI

Parameters

string $uri

JSON Schema URI

null|string $baseUri
$translate

Returns

object —

JSON Schema contents

parse()

parse(string  $uri) : array

Parses a URI into five main components

Parameters

string $uri

Returns

array

generate()

generate(array  $components) : string

Builds a URI based on n array with the main components

Parameters

array $components

Returns

string

resolve()

resolve(string  $uri, string  $baseUri = null) : string

Resolves a URI

Parameters

string $uri

Absolute or relative

string $baseUri

Optional base URI

Returns

string

isValid()

isValid(string  $uri) : boolean

Parameters

string $uri

Returns

boolean

setTranslation()

setTranslation(  $from,   $to) 

Set a URL translation rule

Parameters

$from
$to

translate()

translate(  $uri) 

Apply URI translation rules

Parameters

$uri

loadSchema()

loadSchema(string  $fetchUri) : object

Fetch a schema from the given URI, json-decode it and return it.

Caches schema objects.

Parameters

string $fetchUri

Absolute URI

Returns

object —

JSON schema object