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 ( 34efdb...e71513 )
by Steffen
02:46
created

EcbClientMock::createStreamFromXmlFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace SteffenBrand\CurrCurr\Client;
4
5
use GuzzleHttp\Psr7\Response;
6
use GuzzleHttp\Psr7\Stream;
7
use Psr\Http\Message\ResponseInterface;
8
use SteffenBrand\CurrCurr\Exception\ExchangeRatesRequestFailedException;
9
use SteffenBrand\CurrCurr\Mapper\ExchangeRatesMapper;
10
use SteffenBrand\CurrCurr\Model\ExchangeRate;
11
12
class EcbClientMock implements EcbClientInterface
13
{
14
15
    const VALID_RESPONSE = 'ValidResponse';
16
    const USD_MISSING_RESPONSE = 'UsdMissingResponse';
17
    const DATE_MISSING_RESPONSE = 'DateMissingResponse';
18
19
    /**
20
     * @var ResponseInterface
21
     */
22
    private $response;
23
24
    /**
25
     * @param string $expectedResponse
26
     */
27
    public function __construct(string $expectedResponse)
28
    {
29
        switch ($expectedResponse) {
30 View Code Duplication
            case self::VALID_RESPONSE:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
                $this->response = new Response(
32
                    200,
33
                    [],
34
                    file_get_contents(__DIR__ . '/../../resources/eurofxref-daily-valid.xml')
35
                );
36
                break;
37 View Code Duplication
            case self::USD_MISSING_RESPONSE:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
                $this->response = new Response(
39
                    200,
40
                    [],
41
                    file_get_contents(__DIR__ . '/../../resources/eurofxref-daily-usd-missing.xml')
42
                );
43
                break;
44 View Code Duplication
            case self::DATE_MISSING_RESPONSE:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
                $this->response = new Response(
46
                    200,
47
                    [],
48
                    file_get_contents(__DIR__ . '/../../resources/eurofxref-daily-date-missing.xml')
49
                );
50
                break;
51
        }
52
    }
53
54
    /**
55
     * @throws ExchangeRatesRequestFailedException
56
     * @return ExchangeRate[]
57
     */
58
    public function getExchangeRates(): array
59
    {
60
        $mapper = new ExchangeRatesMapper();
61
        return $mapper->map($this->response);
62
    }
63
64
}