ws/style/uses/docs
[m6w6/seekat] / examples / promise.php
1 #!/usr/bin/env php
2 <?php
3
4 require_once __DIR__."/../vendor/autoload.php";
5
6 use seekat\API;
7
8 $log = new Monolog\Logger("seekat");
9 $log->pushHandler((new Monolog\Handler\StreamHandler(STDERR))->setLevel(Monolog\Logger::INFO));
10
11 $api = new API([
12 "Authorization" => "token ".getenv("GITHUB_TOKEN")
13 ], null, null, $log);
14
15 $api->users->m6w6->gists()->done(function($gists) {
16 foreach ($gists as $gist) {
17 $gist->commits()->then(function($commits) use($gist) {
18 foreach ($commits as $i => $commit) {
19 if (!$i) {
20 printf("\nGist %s, %s:\n", $gist->id, $gist->description ?: "<no title>");
21 }
22 $cs = $commit->change_status;
23 printf("\t%s: ", substr($commit->version,0,8));
24 printf("-%s+%s=%s\n", $cs->deletions, $cs->additions, $cs->total);
25 }
26 });
27 }
28 });
29
30 $api->send();