1 | <?php |
||
5 | class GistFinder |
||
6 | { |
||
7 | /** @var \Github\Api\ApiInterface $gistsApi */ |
||
8 | private $gistsApi; |
||
9 | |||
10 | /** @var \Github\ResultPager $paginator */ |
||
11 | private $paginator; |
||
12 | |||
13 | /** @var \GuzzleHttp\Client $guzzle */ |
||
14 | private $guzzle; |
||
15 | |||
16 | public function __construct( |
||
17 | \Github\Client $githubClient, |
||
18 | \Github\ResultPager $paginator, |
||
19 | \GuzzleHttp\Client $guzzleClient |
||
20 | ) { |
||
21 | $githubClient->authenticate(\Auth::user()->token, null, \Github\Client::AUTH_HTTP_TOKEN); |
||
22 | |||
23 | $this->gistsApi = $githubClient->api('gists'); |
||
24 | $this->paginator = $paginator; |
||
25 | $this->guzzle = $guzzleClient; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get gists and tags. |
||
30 | * |
||
31 | * @return array `['gists' => [...], 'tags' => [...]]` |
||
32 | */ |
||
33 | public function getGistsAndTags() |
||
93 | |||
94 | /** |
||
95 | * Fetch raw gists from GitHub. |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | public function fetchRawGists() |
||
119 | |||
120 | /** |
||
121 | * Get the content of a Gist file. |
||
122 | * |
||
123 | * @param string $url |
||
124 | * |
||
125 | * @return string |
||
126 | */ |
||
127 | public function getGistFileContents($url) |
||
131 | |||
132 | /** |
||
133 | * Separate gist description and tags. |
||
134 | * |
||
135 | * Seeks tags in original gist description and saves them and description separately. |
||
136 | * |
||
137 | * @param string $descriptionWithTags Gist description with optional tags. |
||
138 | * |
||
139 | * @return array `['description' => '...', 'tags' => [...]]` |
||
140 | */ |
||
141 | private function separateDescriptionAndTags($descriptionWithTags) |
||
160 | } |
||
161 |