update to PHP-8.1
[m6w6/seekat] / examples / hooks.php
1 #!/usr/bin/env php
2 <?php
3
4 require_once __DIR__."/../vendor/autoload.php";
5
6 use seekat\API\Links;
7
8 $client = new http\Client("curl", "seekat");
9 $client->configure([
10 "max_host_connections" => 10,
11 "max_total_connections" => 50,
12 "use_eventloop" => true,
13 ]);
14 $api = include "examples.inc";
15
16 $api(function() use($api) {
17 $repos = yield $api->users->m6w6->repos([
18 "visibility" => "public",
19 "affiliation" => "owner"
20 ]);
21 while ($repos) {
22 $next = Links\next($repos);
23
24 $batch = [];
25 foreach ($repos as $repo) {
26 $batch[] = $repo->hooks();
27 }
28 $result = yield $batch;
29 foreach ($result as $key => $hooks) {
30 if (!count($hooks)) {
31 continue;
32 }
33 printf("%s:\n", $repos->{$key}->name);
34 foreach ($hooks as $hook) {
35 if ($hook->name == "web") {
36 printf("\t%s\n", $hook->config->url);
37 } else {
38 printf("\t%s\n", $hook->name);
39 }
40 }
41 }
42
43 $repos = yield $next;
44 }
45 });