Link
MMO\core\server · 1 symbol · generated 5 Oct 2026
Link
Link.php:15A PSR-7 web link (RFC 5988/8288's Link: header entries, e.g. pagination or HATEOAS links): a href plus arbitrary attributes (rel, title, type, ...), array-accessible (tArray) like $link['rel'].
- Namespace
MMO\core\server- Implements
LinkInterface, iArray, Stringable, JsonSerializable- Uses traits
- tArray
Index
| content | ||
| addRel($rel) | Add a relationship type (space-joined into the 'rel' attribute), if it isn't already present. | |
| clear() | Empty the underlying content, keeping the object itself. | |
| count() | \Countable::count | |
| getAttributes() | Returns a list of attributes that describe the target URI. | |
| getHref() | Returns the target of the link. | |
| getIterator() | \IteratorAggregate::getIterator | |
| getRels() | NOTE: this used to return explode(' ', $this->content['rel']??'') -- for a link with no 'rel' set at all, explode(' ', '') returns [''] (one element, an empty string), not [], violating thi… | |
| isEmpty() | ||
| isTemplated() | Returns whether or not this is a templated link. | |
| jsonSerialize() | ||
| keys() | ||
| loadArray($data) | Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. | |
| offsetExists($key) | \ArrayAccess::offsetExists | |
| offsetGet($key) | \ArrayAccess::offsetGet | |
| offsetSet($key, $value) | \ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array. | |
| offsetUnset($key) | \ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain … | |
| toArray() | Convert the content to a plain array, recursively converting any nested iArray value (e.g. | |
| __construct($data, $attributes) | ||
| __toString() |
Properties1
content
Methods19
addRel($rel)
Link.php:37Add a relationship type (space-joined into the 'rel' attribute), if it isn't already present.
clear()
tArray.php:25Empty the underlying content, keeping the object itself.
| returns |
count()
tArray.php:90\Countable::count
| returns | int |
getAttributes()
Link.php:110Returns a list of attributes that describe the target URI.
| returns | array | A key-value list of attributes, where the key is a string and the value is either a PHP primitive or an array of PHP strings. If no values are found an empty array MUST be returned. |
getHref()
Link.php:69Returns the target of the link.
| returns | string |
getIterator()
tArray.php:97\IteratorAggregate::getIterator
| returns | Traversable |
getRels()
Link.php:98NOTE: this used to return explode(' ', $this->content['rel']??'') -- for a link with no 'rel' set at all, explode(' ', '') returns [''] (one element, an empty string), not [], violating this very method's own docblock ("returns 0 or more relationship types") and PSR-7's contract. Verified concretely: count() and empty() both disagreed with "this link has no rel" as a result. Fixed to return [] when there's no rel.
| returns | array |
isEmpty()
tArray.php:33| returns | true if the underlying content has no elements |
isTemplated()
Link.php:79Returns whether or not this is a templated link.
| returns | bool | True if this link object is templated, False otherwise. |
jsonSerialize()
Link.php:52| returns | string | same as __toString -- this link's JSON representation is its raw header-value form. |
keys()
tArray.php:82| returns | array | the list of keys currently set |
loadArray($data)
tArray.php:71Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. for validation or type coercion, is honored for every entry).
offsetExists($key)
tArray.php:130\ArrayAccess::offsetExists
offsetGet($key)
tArray.php:115\ArrayAccess::offsetGet
offsetSet($key, $value)
tArray.php:122\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.
offsetUnset($key)
tArray.php:107\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain PHP list; on an associative array, the key is simply removed.
toArray()
tArray.php:56Convert the content to a plain array, recursively converting any nested iArray value (e.g. another object using this same trait) into its own plain-array form as well.
| returns | array |
__construct($data, $attributes)
Link.php:23| $data = [] | array | string | an href string (or a raw <uri>; attr="value"; ... RFC 8288 header value, decoded via decodeLink), or an already-built attributes array (with an 'href' key). |
| $attributes = null | null | array | extra attributes to merge in when $data is a string. |
__toString()
Link.php:45| returns | string | this link as a raw RFC 8288 <uri>; attr="value"; ... header value (encodeLink). |