9e82d7200aef3ee44f6ca068bb29e6135f873874
3 namespace seekat\Exception
;
5 function message(&$error) : string {
6 if ($error instanceof \Throwable
) {
7 $message = $error->getMessage();
10 $error = new \
Exception($error);
15 namespace seekat\API\Links
;
18 ExtendedPromiseInterface
,
22 use seekat\API\Call\Cache
;
25 * Perform a GET request against the link's "first" relation
27 * @return ExtendedPromiseInterface
29 function first(API
$api, Cache\Service
$cache = null) : ExtendedPromiseInterface
{
30 $links = $api->getLinks();
31 if ($links && ($first = $links->getFirst())) {
32 return $api->withUrl($first)->get(null, null, $cache);
34 return reject($links);
38 * Perform a GET request against the link's "prev" relation
40 * @return ExtendedPromiseInterface
42 function prev(API
$api, Cache\Service
$cache = null) : ExtendedPromiseInterface
{
43 $links = $api->getLinks();
44 if ($links && ($prev = $links->getPrev())) {
45 return $api->withUrl($prev)->get(null, null, $cache);
47 return reject($links);
51 * Perform a GET request against the link's "next" relation
53 * @return ExtendedPromiseInterface
55 function next(API
$api, Cache\Service
$cache = null) : ExtendedPromiseInterface
{
56 $links = $api->getLinks();
57 if ($links && ($next = $links->getNext())) {
58 return $api->withUrl($next)->get(null, null, $cache);
60 return reject($links);
64 * Perform a GET request against the link's "last" relation
66 * @return ExtendedPromiseInterface
68 function last(API
$api, Cache\Service
$cache = null) : ExtendedPromiseInterface
{
69 $links = $api->getLinks();
70 if ($links && ($last = $links->getLast())) {
71 return $api->withUrl($last)->get(null, null, $cache);
73 return reject($links);