f3791258e7f68924f54b5325685b915b9d51967c
3 namespace seekat\API\Links
;
6 use seekat\API\Call\Cache
;
10 * Perform a GET request against the link's "first" relation
12 * @return mixed promise
14 function first(API
$api) {
15 if (($first = $api->getLinks()?
->getFirst())) {
16 return $api->withUrl($first)->get();
18 return $api->getFuture()->resolve(null);
22 * Perform a GET request against the link's "prev" relation
24 * @return mixed promise
26 function prev(API
$api) {
27 if (($prev = $api->getLinks()?
->getPrev())) {
28 return $api->withUrl($prev)->get();
30 return $api->getFuture()->resolve(null);
34 * Perform a GET request against the link's "next" relation
36 * @return mixed promise
38 function next(API
$api) {
39 if (($next = $api->getLinks()?
->getNext())) {
40 return $api->withUrl($next)->get();
42 return $api->getFuture()->resolve(null);
46 * Perform a GET request against the link's "last" relation
48 * @return mixed promise
50 function last(API
$api, Cache\Service
$cache = null) {
51 $links = $api->getLinks();
52 if ($links && ($last = $links->getLast())) {
53 return $api->withUrl($last)->get(null, null, $cache);
55 return $api->getFuture()->resolve(null);