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, Cache\Service
$cache = null) {
15 $links = $api->getLinks();
16 if ($links && ($first = $links->getFirst())) {
17 return $api->withUrl($first)->get(null, null, $cache);
19 return Future\resolve
($api->getFuture(), null);
23 * Perform a GET request against the link's "prev" relation
25 * @return mixed promise
27 function prev(API
$api, Cache\Service
$cache = null) {
28 $links = $api->getLinks();
29 if ($links && ($prev = $links->getPrev())) {
30 return $api->withUrl($prev)->get(null, null, $cache);
32 return Future\resolve
($api->getFuture(), null);
36 * Perform a GET request against the link's "next" relation
38 * @return mixed promise
40 function next(API
$api, Cache\Service
$cache = null) {
41 $links = $api->getLinks();
42 if ($links && ($next = $links->getNext())) {
43 return $api->withUrl($next)->get(null, null, $cache);
45 return Future\resolve
($api->getFuture(), null);
49 * Perform a GET request against the link's "last" relation
51 * @return mixed promise
53 function last(API
$api, Cache\Service
$cache = null) {
54 $links = $api->getLinks();
55 if ($links && ($last = $links->getLast())) {
56 return $api->withUrl($last)->get(null, null, $cache);
58 return Future\resolve
($api->getFuture(), null);