Total Complexity | 4 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class FixerHttpClient extends Client |
||
15 | { |
||
16 | public const BASE_URI = 'http://data.fixer.io/api'; |
||
17 | |||
18 | /** |
||
19 | * Time to wait in seconds before interrupting the request. |
||
20 | */ |
||
21 | public const TIMEOUT = 5; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $apiKey; |
||
27 | |||
28 | /** |
||
29 | * @var SymbolsEndpoint |
||
30 | */ |
||
31 | public $symbols; |
||
32 | |||
33 | /** |
||
34 | * @var LatestExchangeRatesEndpoint |
||
35 | */ |
||
36 | public $rates; |
||
37 | |||
38 | /** |
||
39 | * FixerHttpClient constructor. |
||
40 | * |
||
41 | * @throws MissingAPIKeyException |
||
42 | */ |
||
43 | public function __construct(string $key, array $config = []) |
||
44 | { |
||
45 | if (empty($key)) { |
||
46 | 27 | throw new MissingAPIKeyException(); |
|
47 | } |
||
48 | 27 | ||
49 | 3 | $this->apiKey = $key; |
|
50 | $baseConfig = [ |
||
51 | 'base_uri' => self::BASE_URI, |
||
52 | 24 | RequestOptions::TIMEOUT => self::TIMEOUT, |
|
53 | ]; |
||
54 | 24 | parent::__construct(array_merge($baseConfig, $config)); |
|
55 | 24 | $this->initEndpoints(); |
|
56 | } |
||
57 | 24 | ||
58 | 24 | public function getApiKey(): string |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | 15 | * Initializes all the supported endpoints. |
|
65 | */ |
||
66 | 15 | private function initEndpoints() |
|
72 |