Total Complexity | 3 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class FixerHttpClient extends Client |
||
8 | { |
||
9 | /** |
||
10 | * Library version. |
||
11 | */ |
||
12 | const VERSION = "0.1.0"; |
||
13 | |||
14 | /** |
||
15 | * API base URL. |
||
16 | */ |
||
17 | const BASE_URL = "http://data.fixer.io/api/"; |
||
18 | |||
19 | /** |
||
20 | * How to name the property containing the API key. |
||
21 | */ |
||
22 | const KEY_NAME = "access_key"; |
||
23 | |||
24 | /** |
||
25 | * Default API timeout. |
||
26 | */ |
||
27 | const API_TIMEOUT = 10; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $clientKey; |
||
33 | |||
34 | /** |
||
35 | * FixerHttpClient constructor. |
||
36 | * |
||
37 | * @param string $clientKey |
||
38 | * @param array $options |
||
39 | */ |
||
40 | 21 | public function __construct(string $clientKey, array $options = []) |
|
41 | { |
||
42 | 21 | $opt = array_merge_recursive($options, [ |
|
43 | 21 | 'base_uri' => self::BASE_URL, |
|
44 | 21 | 'timeout' => self::API_TIMEOUT, |
|
45 | 'allow_redirects' => false |
||
46 | ]); |
||
47 | |||
48 | 21 | parent::__construct($opt); |
|
49 | |||
50 | 21 | $this->clientKey = $clientKey; |
|
51 | 21 | } |
|
52 | |||
53 | /** |
||
54 | * Retrieve the API version. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | 3 | public function getAPIVersion(): string |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | 9 | public function getClientKey(): string |
|
71 |