add Amp\Loop example
[m6w6/seekat] / lib / API / Links / functions.php
index eb9b495adedb11354d95b4b44e2cb1f1fb3f61da..f2b87d78123796f487dcc08746abbf453631aa3e 100644 (file)
@@ -10,52 +10,52 @@ use seekat\API\Future;
 /**
  * Perform a GET request against the link's "first" relation
  *
- * @return Promise
+ * @return mixed promise
  */
-function first(API $api, Cache\Service $cache = null) : Promise {
+function first(API $api, Cache\Service $cache = null) {
        $links = $api->getLinks();
        if ($links && ($first = $links->getFirst())) {
                return $api->withUrl($first)->get(null, null, $cache);
        }
-       return Future\reject($api->getFuture(), $links);
+       return Future\resolve($api->getFuture(), null);
 }
 
 /**
  * Perform a GET request against the link's "prev" relation
  *
- * @return Promise
+ * @return mixed promise
  */
-function prev(API $api, Cache\Service $cache = null) : Promise {
+function prev(API $api, Cache\Service $cache = null) {
        $links = $api->getLinks();
        if ($links && ($prev = $links->getPrev())) {
                return $api->withUrl($prev)->get(null, null, $cache);
        }
-       return Future\reject($api->getFuture(), $links);
+       return Future\resolve($api->getFuture(), null);
 }
 
 /**
  * Perform a GET request against the link's "next" relation
  *
- * @return Promise
+ * @return mixed promise
  */
-function next(API $api, Cache\Service $cache = null) : Promise {
+function next(API $api, Cache\Service $cache = null) {
        $links = $api->getLinks();
        if ($links && ($next = $links->getNext())) {
                return $api->withUrl($next)->get(null, null, $cache);
        }
-       return Future\reject($api->getFuture(), $links);
+       return Future\resolve($api->getFuture(), null);
 }
 
 /**
  * Perform a GET request against the link's "last" relation
  *
- * @return Promise
+ * @return mixed promise
  */
-function last(API $api, Cache\Service $cache = null) : Promise {
+function last(API $api, Cache\Service $cache = null) {
        $links = $api->getLinks();
        if ($links && ($last = $links->getLast())) {
                return $api->withUrl($last)->get(null, null, $cache);
        }
-       return Future\reject($api->getFuture(), $links);
+       return Future\resolve($api->getFuture(), null);
 }