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::getExchangeRates()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
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
}