Total Complexity | 5 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class ApiProvider |
||
9 | { |
||
10 | /** @var ClientInterface */ |
||
11 | protected $client; |
||
12 | |||
13 | /** |
||
14 | * ApiProvider constructor. |
||
15 | * |
||
16 | * @param ClientInterface|null $client |
||
17 | */ |
||
18 | public function __construct(ClientInterface $client = null) |
||
19 | { |
||
20 | $this->client = $client; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Get the HTTP client instance. |
||
25 | * |
||
26 | * @return ClientInterface |
||
27 | */ |
||
28 | public function getClient() |
||
29 | { |
||
30 | if (is_null($this->client)) { |
||
31 | return $this->client = $this->createClient(); |
||
32 | } |
||
33 | |||
34 | return $this->client; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Set new HTTP client instance. |
||
39 | * |
||
40 | * @param ClientInterface $client |
||
41 | * |
||
42 | * @return ApiProvider |
||
43 | */ |
||
44 | public function setClient(ClientInterface $client) |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Create new HTTP client. |
||
53 | * |
||
54 | * @return ClientInterface |
||
55 | */ |
||
56 | public function createClient() |
||
61 |