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

ExchangeRates   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 17.65%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 64
loc 64
ccs 3
cts 17
cp 0.1765
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A setFrom() 6 6 1
A setTo() 6 6 1
A getFullEndpoint() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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