LinkCollection
final class LinkCollection implements IteratorAggregate (View source)
| internal | JSON:API maintains no PHP API. The API is the HTTP API. This class may change at any time and could break any dependencies on it. |
Contains a set of JSON:API Link objects.
Properties
| protected Link[] | $links | The links in the collection, keyed by unique strings. |
|
| protected JsonApiDocumentTopLevel|ResourceObject|Relationship | $context | The link context. |
Methods
LinkCollection constructor.
{@inheritdoc}
Whether a link with the given key exists.
Establishes a new context for a LinkCollection.
Gets the LinkCollection's context object.
Filters a LinkCollection using the provided callback.
Ensures that a link key is valid.
Details
__construct(array $links, JsonApiDocumentTopLevel|ResourceObject|Relationship $context = NULL)
LinkCollection constructor.
getIterator()
{@inheritdoc}
LinkCollection
withLink(string $key, Link $new_link)
Gets a new LinkCollection with the given link inserted.
bool
hasLinkWithKey(string $key)
Whether a link with the given key exists.
LinkCollection
withContext(JsonApiDocumentTopLevel|ResourceObject|Relationship $context)
Establishes a new context for a LinkCollection.
JsonApiDocumentTopLevel|ResourceObject|Relationship
getContext()
Gets the LinkCollection's context object.
LinkCollection
filter(callable $f)
Filters a LinkCollection using the provided callback.
static LinkCollection
merge(LinkCollection $a, LinkCollection $b)
Merges two LinkCollections.
static protected bool
validKey(string $key)
Ensures that a link key is valid.