FixerHttpClient   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 62
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAPIVersion() 0 3 1
A __construct() 0 11 1
A getClientKey() 0 3 1
1
<?php
2
3
namespace VictorAvelar\Fixer;
4
5
use GuzzleHttp\Client;
6
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
59
    {
60 3
        return self::VERSION;
61
    }
62
63
    /**
64
     * @return string
65
     */
66 9
    public function getClientKey(): string
67
    {
68 9
        return $this->clientKey;
69
    }
70
}
71