1 | <?php |
||
15 | abstract class Provider implements ProviderInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var Client |
||
19 | */ |
||
20 | protected $client; |
||
21 | |||
22 | /** |
||
23 | * @var PromiseInterface[] |
||
24 | */ |
||
25 | private static $promises = []; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $body; |
||
31 | |||
32 | /** |
||
33 | * VideoLinkGenerator constructor. |
||
34 | * |
||
35 | * @param Client|null $client |
||
36 | */ |
||
37 | public function __construct(Client $client = null) |
||
41 | |||
42 | /** |
||
43 | * Unwrap Promises. |
||
44 | */ |
||
45 | public function __destruct() |
||
49 | |||
50 | /** |
||
51 | * @param $url |
||
52 | */ |
||
53 | abstract public function getVideoInfo($url); |
||
54 | |||
55 | /** |
||
56 | * Sets HTTP client. |
||
57 | * |
||
58 | * @param $client |
||
59 | * |
||
60 | * @return $this |
||
61 | */ |
||
62 | public function setClient($client) |
||
68 | |||
69 | /** |
||
70 | * Gets HTTP client for internal class use. |
||
71 | * |
||
72 | * @return Client |
||
73 | */ |
||
74 | public function getClient() |
||
78 | |||
79 | /** |
||
80 | * Returns Raw Response Body. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getBody() |
||
88 | |||
89 | /** |
||
90 | * Get Page Source Code. |
||
91 | * |
||
92 | * @param $url |
||
93 | * |
||
94 | * @throws VideoDownloaderException |
||
95 | */ |
||
96 | public function getSourceCode($url) |
||
108 | |||
109 | /** |
||
110 | * Download remote file from server |
||
111 | * and save it locally using HTTP Client. |
||
112 | * |
||
113 | * @param string $url The URL to Remote File to Download. |
||
114 | * @param string $dstFilename Destination Filename (Accepts File Path too). |
||
115 | * @param bool $isAsyncRequest |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | public function download($url, $dstFilename, $isAsyncRequest = false) |
||
130 | |||
131 | /** |
||
132 | * Make a HTTP Request. |
||
133 | * |
||
134 | * @param $url |
||
135 | * @param array $options |
||
136 | * @param bool|false $isAsyncRequest |
||
137 | * |
||
138 | * @return mixed |
||
139 | */ |
||
140 | private function httpRequest($url, array $options = [], $isAsyncRequest = false) |
||
162 | |||
163 | /** |
||
164 | * Prepares and returns request options. |
||
165 | * |
||
166 | * @param array $headers |
||
167 | * @param $options |
||
168 | * @param $isAsyncRequest |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | private function getOptions(array $headers, $options = [], $isAsyncRequest = false) |
||
181 | |||
182 | /** |
||
183 | * Returns Default Headers for HTTP Client. |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | protected function defaultHeaders() |
||
194 | |||
195 | /** |
||
196 | * Decode Unicode Sequences. |
||
197 | * |
||
198 | * @param $str |
||
199 | * |
||
200 | * @return mixed |
||
201 | */ |
||
202 | protected function decodeUnicode($str) |
||
210 | |||
211 | /** |
||
212 | * Cleanup string to readible text. |
||
213 | * |
||
214 | * @param string $str |
||
215 | * |
||
216 | * @return string |
||
217 | */ |
||
218 | protected function cleanStr($str) |
||
222 | |||
223 | /** |
||
224 | * @param $uni |
||
225 | * |
||
226 | * @return bool|mixed|string |
||
227 | */ |
||
228 | protected function replace_unicode_escape_sequence($uni) |
||
232 | } |
||
233 |
If you suppress an error, we recommend checking for the error condition explicitly: