update to PHP-8.1
[m6w6/seekat] / lib / API / Call.php
1 <?php
2
3 namespace seekat\API;
4
5 use http\Url;
6 use seekat\API;
7
8 final class Call {
9 function __construct(private readonly API $api, private readonly string $call) {
10 }
11
12 function __invoke(array $args) {
13 if ($this->api->exists($this->call."_url", $url)) {
14 $url = new Url(uri_template($url, (array) current($args)));
15 $promise = $this->api->withUrl($url)->get(...$args);
16 } else {
17 $promise = $this->api->{$this->call}->get(...$args);
18 }
19
20 return $promise;
21 }
22 }