1 | <?php |
||
7 | class HubphAPI |
||
8 | { |
||
9 | protected $config; |
||
10 | protected $gitHubAPI; |
||
11 | protected $as = 'default'; |
||
12 | |||
13 | /** |
||
14 | * HubphAPI constructor |
||
15 | */ |
||
16 | public function __construct(ConfigInterface $config) |
||
20 | |||
21 | public function setAs($as) |
||
28 | |||
29 | public function whoami() |
||
35 | |||
36 | public function prClose($org, $project, $number) |
||
43 | |||
44 | public function prCheck($projectWithOrg, $vids) |
||
66 | |||
67 | protected function existingPRs($gitHubAPI, $projectWithOrg, $vids) |
||
83 | |||
84 | /** |
||
85 | * Authenticate and then return the gitHub API object. |
||
86 | */ |
||
87 | public function gitHubAPI() |
||
97 | |||
98 | /** |
||
99 | * Look up the GitHub token set either via environment variable or in the |
||
100 | * auth-token cache directory. |
||
101 | */ |
||
102 | public function gitHubToken() |
||
103 | { |
||
104 | $as = $this->as; |
||
105 | if ($as == 'default') { |
||
106 | $as = $this->getConfig()->get("github.default-user"); |
||
107 | } |
||
108 | $github_token_cache = $this->getConfig()->get("github.personal-auth-token.$as.path"); |
||
109 | if (file_exists($github_token_cache)) { |
||
110 | $token = trim(file_get_contents($github_token_cache)); |
||
111 | putenv("GITHUB_TOKEN=$token"); |
||
112 | } else { |
||
113 | $token = getenv('GITHUB_TOKEN'); |
||
114 | } |
||
115 | |||
116 | return $token; |
||
117 | } |
||
118 | |||
119 | protected function getConfig() |
||
123 | } |
||
124 |