namespace seekat\API;
+use http\{Header, Params, QueryString, Url};
use seekat\Exception\UnexpectedValueException;
-use http\ {
- Header,
- Params,
- QueryString,
- Url
-};
use Serializable;
-class Links implements Serializable
-{
+final class Links implements Serializable {
/**
* Parsed "Link" relations
* @var Params
* @param Header $links The Link header
* @throws UnexpectedValueException
*/
- function __construct(Header $links) {
- if (strcasecmp($links->name, "Link")) {
- throw new UnexpectedValueException("Expected 'Link' header, got: '{$links->name}'");
+ function __construct(Header $links = null) {
+ if ($links) {
+ if (strcasecmp($links->name, "Link")) {
+ throw new UnexpectedValueException("Expected 'Link' header, got: '{$links->name}'");
+ }
+ $this->unserialize($links->value);
}
- $this->unserialize($links->value);
}
/**