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 ( ce7cc4...e46035 )
by Steffen
03:11
created

EcbClient::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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
     * @const string
16
     */
17
    const HTTP_GET = 'GET';
18
19
    /**
20
     * @const string
21
     */
22
    const DEFAULT_EXCHANGE_RATES_URL = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml';
23
24
    /**
25
     * @var Client
26
     */
27
    private $client;
28
29
    /**
30
     * @var string
31
     */
32
    private $exchangeRatesUrl;
33
34
    /**
35
     * @param string $exchangeRatesUrl
36
     */
37
    public function __construct(string $exchangeRatesUrl = null)
38
    {
39
        if (null === $exchangeRatesUrl) {
40
            $this->exchangeRatesUrl = self::DEFAULT_EXCHANGE_RATES_URL
41
        } else {
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '}'
Loading history...
42
            $this->exchangeRatesUrl = $exchangeRatesUrl;   
43
        }
44
        $this->client = new Client();
45
    }
46
47
    /**
48
     * @throws ExchangeRatesRequestFailedException
49
     * @return ExchangeRate[]
50
     */
51
    public function getExchangeRates(): array
52
    {
53
        try {
54
            $response = $this->client->request(self::HTTP_GET, $this->exchangeRatesUrl);
55
        } catch (Exception $e) {
56
            throw new ExchangeRatesRequestFailedException($e);
57
        }
58
59
        $mapper = new ExchangeRatesMapper();
60
        return $mapper->map($response);
61
    }
62
63
}
64