Total Complexity | 4 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | abstract class AbstractApi |
||
10 | { |
||
11 | protected $client; |
||
12 | |||
13 | 39 | public function __construct(Client $client) |
|
14 | { |
||
15 | 39 | $this->client = $client; |
|
16 | 39 | } |
|
17 | |||
18 | /** |
||
19 | * @param string $url |
||
20 | * @return mixed |
||
21 | * @throws ClientException |
||
22 | */ |
||
23 | 27 | protected function get(string $url) |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $url |
||
31 | * @param array $data |
||
32 | * @return mixed |
||
33 | * @throws ClientException |
||
34 | */ |
||
35 | 9 | protected function post(string $url, array $data = []) |
|
36 | { |
||
37 | 9 | $guzzleClient = $this->client->getHttpClient(); |
|
38 | 9 | return $this->decodeJson($guzzleClient->post($url, ['json' => $data])->getBody()); |
|
39 | } |
||
40 | |||
41 | 36 | protected function decodeJson(string $json) |
|
44 | } |
||
45 | } |
||
46 |