Completed
Pull Request — master (#1)
by Victor Hugo
04:00
created

FixerHttpClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 11
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php
2
3
namespace Deltatuts\Fixer;
4
5
use Deltatuts\Fixer\Exception\MissingAPIKeyException;
6
use GuzzleHttp\Client;
7
use GuzzleHttp\RequestOptions;
8
9
/**
10
 * Class FixerHttpClient
11
 * @package Deltatuts\Fixer
12
 */
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
    public function __construct(string $key, array $config = [])
40
    {
41
        if (empty($key)) {
42
            throw new MissingAPIKeyException();
43
        }
44
45
        $this->apiKey = $key;
46
        $baseConfig = [
47
            'base_uri' => self::BASE_URI,
48
            RequestOptions::TIMEOUT => self::TIMEOUT
49
        ];
50
        parent::__construct(array_merge($baseConfig, $config));
51
    }
52
}
53