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