basic async-interop support; generator consumer missing
[m6w6/seekat] / lib / API / Links.php
index 7022cda2c9ea8c85d27ad6a58cfd58b99bbea2dc..322eb8e847115557cacbf33e799a442da71470fa 100644 (file)
@@ -11,7 +11,7 @@ use http\ {
 };
 use Serializable;
 
-class Links implements Serializable
+final class Links implements Serializable
 {
        /**
         * Parsed "Link" relations
@@ -31,11 +31,13 @@ class Links implements Serializable
         * @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);
        }
 
        /**