Total Complexity | 4 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | abstract class AbstractHttpClient implements HttpClientInterface |
||
8 | { |
||
9 | public function request($url, array $data = null) |
||
10 | { |
||
11 | $response = $this->doRequest($url, $data); |
||
12 | |||
13 | if (!isset($response['ok']) || !$response['ok']) { |
||
14 | throw new Exception($response['description'], $response['error_code']); |
||
15 | } |
||
16 | |||
17 | return $response['result']; |
||
18 | } |
||
19 | |||
20 | public function download($url) |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param string $url |
||
27 | * @param array|null $data |
||
28 | * @return array |
||
29 | */ |
||
30 | abstract protected function doRequest($url, array $data = null); |
||
31 | |||
32 | /** |
||
33 | * @param string $url |
||
34 | * @return string |
||
35 | */ |
||
36 | abstract protected function doDownload($url); |
||
37 | } |
||
38 |