PHP8
[m6w6/seekat] / lib / API / Links.php
index 7022cda2c9ea8c85d27ad6a58cfd58b99bbea2dc..20fbc6d846ec3226beb3ee518ade5e6161da69e3 100644 (file)
@@ -2,17 +2,11 @@
 
 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
@@ -31,11 +25,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);
        }
 
        /**