repo checks
[pharext/pharext.org] / app / Github / Fetch / Contents.php
1 <?php
2
3 namespace app\Github\Fetch;
4
5 use app\Github\Exception\ContentsFetchFailed;
6 use app\Github\Fetch;
7 use http\Client\Request;
8
9 class Contents extends Fetch
10 {
11 function getRequest() {
12 $url = $this->url->mod(sprintf("/repos/%s/contents/%s",
13 $this->args["repo"], $this->args["path"]));
14 return new Request("GET", $url, [
15 "Accept" => "application/vnd.github.v3+json",
16 "Authorization" => "token " . $this->api->getToken()
17 ]);
18 }
19
20 function getException($message, $code, $previous = null) {
21 return new ContentsFetchFailed($message, $code, $previous);
22 }
23
24 function getCacheKey() {
25 return $this->api->getCacheKey(sprintf("contents:%s:%s",
26 $this->args["repo"], $this->args["path"]));
27 }
28 }