X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2FAPI%2FLinks%2Ffunctions.php;h=f3791258e7f68924f54b5325685b915b9d51967c;hb=HEAD;hp=eb9b495adedb11354d95b4b44e2cb1f1fb3f61da;hpb=f4aa6beaf2e1f0dc9c877782cbbad5a989194517;p=m6w6%2Fseekat diff --git a/lib/API/Links/functions.php b/lib/API/Links/functions.php index eb9b495..f379125 100644 --- a/lib/API/Links/functions.php +++ b/lib/API/Links/functions.php @@ -2,7 +2,6 @@ namespace seekat\API\Links; -use AsyncInterop\Promise; use seekat\API; use seekat\API\Call\Cache; use seekat\API\Future; @@ -10,52 +9,49 @@ 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 { - $links = $api->getLinks(); - if ($links && ($first = $links->getFirst())) { - return $api->withUrl($first)->get(null, null, $cache); +function first(API $api) { + if (($first = $api->getLinks()?->getFirst())) { + return $api->withUrl($first)->get(); } - return Future\reject($api->getFuture(), $links); + return $api->getFuture()->resolve(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 { - $links = $api->getLinks(); - if ($links && ($prev = $links->getPrev())) { - return $api->withUrl($prev)->get(null, null, $cache); +function prev(API $api) { + if (($prev = $api->getLinks()?->getPrev())) { + return $api->withUrl($prev)->get(); } - return Future\reject($api->getFuture(), $links); + return $api->getFuture()->resolve(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 { - $links = $api->getLinks(); - if ($links && ($next = $links->getNext())) { - return $api->withUrl($next)->get(null, null, $cache); +function next(API $api) { + if (($next = $api->getLinks()?->getNext())) { + return $api->withUrl($next)->get(); } - return Future\reject($api->getFuture(), $links); + return $api->getFuture()->resolve(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 $api->getFuture()->resolve(null); }