1 | <?php |
||
15 | class GithubStrategy implements StrategyInterface |
||
16 | { |
||
17 | const API_URL = 'https://api.github.com/repos/%s/%s/releases/latest'; |
||
18 | |||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | private $stability = StrategyInterface::STABILITY_STABLE; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $githubOwner = ''; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $githubRepo = ''; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $pharFile = ''; |
||
38 | |||
39 | /** |
||
40 | * @var HttpClientFactory |
||
41 | */ |
||
42 | private $httpClientFactory; |
||
43 | |||
44 | /** |
||
45 | * @var array |
||
46 | */ |
||
47 | private $lastResponse = []; |
||
48 | |||
49 | /** |
||
50 | * @param HttpClientFactory $httpClientFactory |
||
51 | */ |
||
52 | 3 | public function __construct( |
|
58 | |||
59 | /** |
||
60 | * @return string |
||
61 | * @throws StrategyException |
||
62 | */ |
||
63 | 2 | public function getLatestVersion() |
|
81 | |||
82 | /** |
||
83 | * |
||
84 | */ |
||
85 | 1 | public function downloadLatestVersion() |
|
91 | |||
92 | /** |
||
93 | * @param int $stability |
||
94 | */ |
||
95 | public function setStability($stability) |
||
99 | |||
100 | /** |
||
101 | * @param $pharFileName |
||
102 | */ |
||
103 | 1 | public function setPharFile($pharFileName) |
|
107 | |||
108 | /** |
||
109 | * @param string $owner |
||
110 | */ |
||
111 | 3 | public function setGithubOwner($owner) |
|
115 | |||
116 | /** |
||
117 | * @param string $repo |
||
118 | */ |
||
119 | 3 | public function setGithubRepo($repo) |
|
123 | |||
124 | /** |
||
125 | * @return \PSU\HttpClient\HttpClientInterface |
||
126 | */ |
||
127 | 3 | private function getHttpClient() |
|
131 | |||
132 | /** |
||
133 | * @return string |
||
134 | * @throws StrategyException |
||
135 | */ |
||
136 | 3 | private function getApiCallUrl() |
|
152 | |||
153 | /** |
||
154 | * @return array |
||
155 | * @throws StrategyException |
||
156 | */ |
||
157 | 3 | private function getReleaseInfo() |
|
168 | |||
169 | /** |
||
170 | * @return string |
||
171 | */ |
||
172 | 1 | private function getPharDownloadUrl() |
|
186 | } |