Test Failed
Pull Request — master (#13)
by
unknown
04:04
created

ExchangeRates::getFullEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 0
cts 8
cp 0
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Digitonic\IexCloudSdk\ForexCurrencies;
4
5
use Digitonic\IexCloudSdk\Contracts\IEXCloud;
6
use Digitonic\IexCloudSdk\Requests\BaseRequest;
7
8 View Code Duplication
class ExchangeRates extends BaseRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
9
{
10
    const ENDPOINT = 'fx/rate/{from}/{to}';
11
12
    /**
13
     * @var string
14
     */
15
    private $fromCurrency = 'USD';
16
17
    /**
18
     * @var string
19
     */
20
    private $toCurrency = 'GBP';
21
22
    /**
23
     * Create constructor.
24
     *
25
     * @param  IEXCloud  $api
26
     */
27 1
    public function __construct(IEXCloud $api)
28
    {
29 1
        parent::__construct($api);
30 1
    }
31
32
    /**
33
     * @param  string  $fromCurrency
34
     *
35
     * @return ExchangeRates
36
     */
37
    public function setFrom(string $fromCurrency): self
38
    {
39
        $this->fromCurrency = $fromCurrency;
40
41
        return $this;
42
    }
43
44
    /**
45
     * @param  string  $toCurrency
46
     *
47
     * @return ExchangeRates
48
     */
49
    public function setTo(string $toCurrency): self
50
    {
51
        $this->toCurrency = $toCurrency;
52
53
        return $this;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    protected function getFullEndpoint(): string
60
    {
61
        return str_replace(
62
            '{from}',
63
            $this->fromCurrency,
64
            str_replace(
65
                '{to}',
66
                $this->toCurrency,
67
                self::ENDPOINT
68
            )
69
        );
70
    }
71
}
72