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

SsrStatus   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 49
loc 49
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A setSymbols() 6 6 1
A getFullEndpoint() 4 4 1
A validateParams() 6 6 2

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\InvestorsExchangeData\Deep;
4
5
use Digitonic\IexCloudSdk\Contracts\IEXCloud;
6
use Digitonic\IexCloudSdk\Exceptions\WrongData;
7
use Digitonic\IexCloudSdk\Requests\BaseRequest;
8
9 View Code Duplication
class SsrStatus 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...
10
{
11
    const ENDPOINT = 'deep/ssr-status?symbols={symbols}';
12
13
    /**
14
     * @var string
15
     */
16
    private $symbols;
17
18
    /**
19
     * Create constructor.
20
     *
21
     * @param  IEXCloud  $api
22
     */
23 2
    public function __construct(IEXCloud $api)
24
    {
25 2
        parent::__construct($api);
26 2
    }
27
28
    /**
29
     * @param  mixed  ...$symbols
30
     *
31
     * @return SsrStatus
32
     */
33
    public function setSymbols(...$symbols): self
34
    {
35
        $this->symbols = implode(',', $symbols);
36
37
        return $this;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    protected function getFullEndpoint(): string
44
    {
45
        return str_replace('{symbols}', $this->symbols, self::ENDPOINT);
46
    }
47
48
    /**
49
     * @return bool|void
50
     */
51 1
    protected function validateParams(): void
52
    {
53 1
        if (empty($this->symbols)) {
54 1
            throw WrongData::invalidValuesProvided('Please provide symbol(s) to query!');
55
        }
56
    }
57
}
58