update to PHP-8.1
[m6w6/seekat] / examples / hooks.php
index dfcb6359d51d19bf154570cb8e761ab90cae90a8..fdeca097cb281c0921e596115c5ac0bfec2bd985 100755 (executable)
@@ -3,20 +3,15 @@
 
 require_once __DIR__."/../vendor/autoload.php";
 
-use seekat\{API, API\Future, API\Links};
-use Monolog\{Logger, Handler};
+use seekat\API\Links;
 
-$cli = new http\Client("curl", "seekat");
-$cli->configure([
+$client = new http\Client("curl", "seekat");
+$client->configure([
        "max_host_connections" => 10,
        "max_total_connections" => 50,
        "use_eventloop" => true,
 ]);
-
-$log = new Logger("seekat");
-$log->pushHandler(new Handler\StreamHandler(STDERR, Logger::NOTICE));
-
-$api = new API(Future\react(), API\auth("token", getenv("GITHUB_TOKEN")), null, $cli, $log);
+$api = include "examples.inc";
 
 $api(function() use($api) {
        $repos = yield $api->users->m6w6->repos([
@@ -30,7 +25,8 @@ $api(function() use($api) {
                foreach ($repos as $repo) {
                        $batch[] = $repo->hooks();
                }
-               foreach (yield $batch as $key => $hooks) {
+               $result = yield $batch;
+               foreach ($result as $key => $hooks) {
                        if (!count($hooks)) {
                                continue;
                        }