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 ( 20e334...2a232d )
by Steffen
03:00
created

EcbClientMock::__construct()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 41
Code Lines 26

Duplication

Lines 36
Ratio 87.8 %

Importance

Changes 0
Metric Value
dl 36
loc 41
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 26
nc 4
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
    /**
16
     * @var ResponseInterface
17
     */
18
    private $response;
19
20
    /**
21
     * @param string $expectedResponse
22
     */
23
    public function __construct(string $expectedResponse)
24
    {
25
        switch ($expectedResponse) {
26 View Code Duplication
            case 'ValidResponse':
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...
27
                $this->response = new Response(
28
                    200,
29
                    [],
30
                    new Stream(
31
                        fopen(
32
                            'data://application/xml,' . file_get_contents(__DIR__ . '/../../resources/eurofxref-daily-valid.xml'),
33
                            'r'
34
                        )
35
                    )
36
                );
37
                break;
38 View Code Duplication
            case 'UsdMissingResponse':
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...
39
                $this->response = new Response(
40
                    200,
41
                    [],
42
                    new Stream(
43
                        fopen(
44
                            'data://application/xml,' . file_get_contents(__DIR__ . '/../../resources/eurofxref-daily-usd-missing.xml'),
45
                            'r'
46
                        )
47
                    )
48
                );
49
                break;
50 View Code Duplication
            case 'DateMissingResponse':
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...
51
                $this->response = new Response(
52
                    200,
53
                    [],
54
                    new Stream(
55
                        fopen(
56
                            'data://application/xml,' . file_get_contents(__DIR__ . '/../../resources/eurofxref-daily-date-missing.xml'),
57
                            'r'
58
                        )
59
                    )
60
                );
61
                break;
62
        }
63
    }
64
65
    /**
66
     * @throws ExchangeRatesRequestFailedException
67
     * @return ExchangeRate[]
68
     */
69
    public function getExchangeRates(): array
70
    {
71
        $mapper = new ExchangeRatesMapper();
72
        return $mapper->map($this->response);
73
    }
74
75
}