flush
[m6w6/seekat] / lib / API / Links.php
index 325f4b7289875e1a415f911489d4b4dafd254da9..322eb8e847115557cacbf33e799a442da71470fa 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace seekat\API;
 
+use seekat\Exception\UnexpectedValueException;
 use http\ {
        Header,
        Params,
@@ -9,9 +10,8 @@ use http\ {
        Url
 };
 use Serializable;
-use UnexpectedValueException;
 
-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);
        }
 
        /**