yet another github api refactoring
[pharext/pharext.org] / app / Github / API / Repos / ContentsCallback.php
1 <?php
2
3 namespace app\Github\API\Repos;
4
5 use app\Github\API;
6 use app\Github\API\Callback;
7
8 class ContentsCallback extends Callback
9 {
10 private $repo;
11
12 function __construct(API $api, $repo) {
13 parent::__construct($api);
14 $this->repo = $repo;
15 }
16
17 function __invoke($json, $links = null) {
18 foreach ($json as $entry) {
19 if ($entry->type !== "file" || $entry->size <= 0) {
20 continue;
21 }
22 if ($entry->name === "config.m4" || fnmatch("config?.m4", $entry->name)) {
23 $this->repo->config_m4 = $entry->name;
24 } elseif ($entry->name === "package.xml" || $entry->name === "package2.xml") {
25 $this->repo->package_xml = $entry->name;
26 } elseif ($entry->name === "pharext_package.php") {
27 $this->repo->pharext_package_php = $entry->name;
28 }
29 }
30 }
31 }