Documentation

Resource
in package
implements ResourceInterface

The Resource Object described in the JSON Hypertext Application Language (draft-kelly-json-hal-07).

Tags
see
https://datatracker.ietf.org/doc/html/draft-kelly-json-hal-07#section-4

Note: When trying to find a Link or an embedded Resource by their relation type (Rel), the search is done by comparing the lower-case relation name.

"When extension relation types are compared, they MUST be compared as strings [...] in a case-insensitive fashion."

see
https://tools.ietf.org/html/rfc5988#section-4.2

Interfaces, Classes, Traits and Enums

ResourceInterface
The Resource Object described in the JSON Hypertext Application Language (draft-kelly-json-hal-07).

Table of Contents

$embeddedResources  : mixed
$links  : mixed
$state  : mixed
__construct()  : mixed
Create a new Resource.
fromJson()  : resource
Builds a Resource from its JSON representation.
getAllEmbeddedResources()  : array<string|int, mixed>
All the embedded resources directly available in the resource.
getAllLinks()  : array<string|int, mixed>
All the links directly available in the resource.
getEmbeddedResource()  : resource
Finds a unique embedded resource by its relation type.
getEmbeddedResources()  : array<string|int, mixed>
Finds an array of embedded resources by their relation type.
getLink()  : Link
Finds a unique link by its relation type.
getLinks()  : array<string|int, mixed>
Finds an array of links by their relation type.
getState()  : array<string|int, mixed>
All the properties of the resource ("_links" and "_embedded" not included).
extractByRel()  : mixed
extractState()  : mixed
findByRel()  : mixed
Looks for the given relation name in a case-insensitive fashion and returns the corresponding value.

Properties

$embeddedResources

private mixed $embeddedResources

Methods

__construct()

Create a new Resource.

public __construct([array<string|int, mixed> $state = null ][, array<string|int, mixed> $links = null ][, array<string|int, mixed> $embeddedResources = null ]) : mixed
Parameters
$state : array<string|int, mixed> = null
$links : array<string|int, mixed> = null
$embeddedResources : array<string|int, mixed> = null
Return values
mixed

fromJson()

Builds a Resource from its JSON representation.

public static fromJson(mixed $json) : resource
Parameters
$json : mixed

A JSON representing the resource

Return values
resource

getAllEmbeddedResources()

All the embedded resources directly available in the resource.

public getAllEmbeddedResources() : array<string|int, mixed>
Return values
array<string|int, mixed>

All the links directly available in the resource.

public getAllLinks() : array<string|int, mixed>
Return values
array<string|int, mixed>

getEmbeddedResource()

Finds a unique embedded resource by its relation type.

public getEmbeddedResource(mixed $rel) : resource
Parameters
$rel : mixed

The relation type

Return values
resource

the Resource referenced by the given rel

getEmbeddedResources()

Finds an array of embedded resources by their relation type.

public getEmbeddedResources(mixed $rel) : array<string|int, mixed>
Parameters
$rel : mixed

The relation type

Return values
array<string|int, mixed>

Array of embedded resources referenced by the given rel

Finds a unique link by its relation type.

public getLink(mixed $rel) : Link
Parameters
$rel : mixed

The relation type

Return values
Link

the Link referenced by the given rel

Finds an array of links by their relation type.

public getLinks(mixed $rel) : array<string|int, mixed>
Parameters
$rel : mixed

The relation type

Return values
array<string|int, mixed>

Array of links referenced by the given rel

getState()

All the properties of the resource ("_links" and "_embedded" not included).

public getState() : array<string|int, mixed>
Return values
array<string|int, mixed>

extractByRel()

private static extractByRel(array<string|int, mixed> $json, string $rel) : mixed
Parameters
$json : array<string|int, mixed>
$rel : string
Return values
mixed

extractState()

private static extractState(array<string|int, mixed> $json) : mixed
Parameters
$json : array<string|int, mixed>
Return values
mixed

findByRel()

Looks for the given relation name in a case-insensitive fashion and returns the corresponding value.

private static findByRel(array<string|int, mixed> $a, string $rel) : mixed
Parameters
$a : array<string|int, mixed>

The relation array

$rel : string

The relation name

Return values
mixed

the value in $a matching the relation name or null if not found

Search results