1 | <?php |
||
22 | class Resolver |
||
23 | { |
||
24 | /** |
||
25 | * Guzzle client |
||
26 | * @var Client |
||
27 | */ |
||
28 | private $client; |
||
29 | |||
30 | /** |
||
31 | * Guzzle cookie |
||
32 | * @var CookieJar |
||
33 | */ |
||
34 | private $cookie; |
||
35 | |||
36 | /** |
||
37 | * Ubench lib |
||
38 | * @var Ubench |
||
39 | */ |
||
40 | private $bench; |
||
41 | |||
42 | /** |
||
43 | * Retry download on connection fail |
||
44 | * @var int |
||
45 | */ |
||
46 | private $retryDownload = false; |
||
47 | |||
48 | /** |
||
49 | * Receives dependencies |
||
50 | * |
||
51 | * @param Client $client |
||
52 | * @param Ubench $bench |
||
53 | * @param bool $retryDownload |
||
54 | */ |
||
55 | public function __construct(Client $client, Ubench $bench, $retryDownload = false) |
||
62 | |||
63 | /** |
||
64 | * Grabs all lessons & series from the website. |
||
65 | */ |
||
66 | public function getAllLessons() |
||
81 | |||
82 | /** |
||
83 | * Gets the latest lessons only. |
||
84 | * |
||
85 | * @return array |
||
86 | * |
||
87 | * @throws \Exception |
||
88 | */ |
||
89 | public function getLatestLessons() |
||
98 | |||
99 | /** |
||
100 | * Gets the html from the all page. |
||
101 | * |
||
102 | * @return string |
||
103 | * |
||
104 | * @throws \Exception |
||
105 | */ |
||
106 | private function getAllPage() |
||
112 | |||
113 | /** |
||
114 | * Tries to auth. |
||
115 | * |
||
116 | * @param $email |
||
117 | * @param $password |
||
118 | * |
||
119 | * @return bool |
||
120 | * @throws SubscriptionNotActiveException |
||
121 | */ |
||
122 | public function doAuth($email, $password) |
||
154 | |||
155 | /** |
||
156 | * Download the episode of the serie. |
||
157 | * |
||
158 | * @param $serie |
||
159 | * @param $episode |
||
160 | * @return bool |
||
161 | */ |
||
162 | public function downloadSerieEpisode($serie, $episode) |
||
175 | |||
176 | /** |
||
177 | * Downloads the lesson. |
||
178 | * |
||
179 | * @param $lesson |
||
180 | * @return bool |
||
181 | */ |
||
182 | public function downloadLesson($lesson) |
||
194 | |||
195 | /** |
||
196 | * Helper function to get html of a page |
||
197 | * @param $path |
||
198 | * @return string |
||
199 | */ |
||
200 | private function getPage($path) { |
||
206 | |||
207 | /** |
||
208 | * Helper to get the Location header. |
||
209 | * |
||
210 | * @param $url |
||
211 | * |
||
212 | * @return string |
||
213 | */ |
||
214 | private function getRedirectUrl($url) |
||
224 | |||
225 | /** |
||
226 | * Gets the name of the serie episode. |
||
227 | * |
||
228 | * @param $html |
||
229 | * |
||
230 | * @param $path |
||
231 | * @return string |
||
232 | */ |
||
233 | private function getNameOfEpisode($html, $path) |
||
239 | |||
240 | /** |
||
241 | * Helper to download the video. |
||
242 | * |
||
243 | * @param $html |
||
244 | * @param $saveTo |
||
245 | * @return bool |
||
246 | */ |
||
247 | private function downloadLessonFromPath($html, $saveTo) |
||
310 | } |
||
311 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.