GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 38bb0b...1696f4 )
by Steffen
03:48
created

EcbClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getExchangeRates() 0 11 2
1
<?php
2
3
namespace SteffenBrand\CurrCurr\Client;
4
5
use Exception;
6
use GuzzleHttp\Client;
7
use SteffenBrand\CurrCurr\Exception\ExchangeRatesRequestFailedException;
8
use SteffenBrand\CurrCurr\Mapper\ExchangeRatesMapper;
9
use SteffenBrand\CurrCurr\Model\ExchangeRate;
10
11
class EcbClient implements EcbClientInterface
12
{
13
14
    /**
15
     * @var Client
16
     */
17
    private $client;
18
19
    /**
20
     * @var string
21
     */
22
    private $exchangeRatesUrl;
23
24
    /**
25
     * @param string $exchangeRatesUrl
26
     */
27
    public function __construct(string $exchangeRatesUrl = self::DEFAULT_EXCHANGE_RATES_URL)
28
    {
29
        $this->exchangeRatesUrl = $exchangeRatesUrl;
30
        $this->client = new Client();
31
    }
32
33
    /**
34
     * @throws ExchangeRatesRequestFailedException
35
     * @return ExchangeRate[]
36
     */
37
    public function getExchangeRates(): array
38
    {
39
        try {
40
            $response = $this->client->request(self::HTTP_GET, $this->exchangeRatesUrl);
41
        } catch (Exception $e) {
42
            throw new ExchangeRatesRequestFailedException($e);
43
        }
44
45
        $mapper = new ExchangeRatesMapper();
46
        return $mapper->map($response);
47
    }
48
49
}