Total Complexity | 9 |
Total Lines | 75 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 5 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | abstract class BaseApi |
||
9 | { |
||
10 | /** |
||
11 | * HTTP client implementation. |
||
12 | * |
||
13 | * @var \GuzzleHttp\ClientInterface |
||
14 | */ |
||
15 | protected $client; |
||
16 | |||
17 | /** |
||
18 | * Contentful configuration. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $config; |
||
23 | |||
24 | /** |
||
25 | * API base URL. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $baseUrl; |
||
30 | |||
31 | /** |
||
32 | * API preview Base URL. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $previewBaseUrl; |
||
37 | |||
38 | /** |
||
39 | * BaseApi constructor. |
||
40 | * |
||
41 | * @param \GuzzleHttp\ClientInterface $client |
||
42 | * @return void |
||
43 | */ |
||
44 | public function __construct(ClientInterface $client) |
||
45 | { |
||
46 | $this->client = $client; |
||
47 | |||
48 | $this->config = config('contentful', []); |
||
49 | $this->config = ! is_array($this->config) ? (array)$this->config : $this->config; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Return endpoint URL. |
||
54 | * |
||
55 | * @param string $endpoint |
||
56 | * @return string |
||
57 | */ |
||
58 | protected function url($endpoint): string |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Decode given response. |
||
76 | * |
||
77 | * @param \Psr\Http\Message\ResponseInterface $response |
||
78 | * @return array |
||
79 | */ |
||
80 | protected function decodeResponse(ResponseInterface $response): array |
||
85 |