Passed
Push — master ( f13907...f1392d )
by Steven
56s queued 12s
created

Tops   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 46
loc 46
ccs 12
cts 12
cp 1
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;
4
5
use Digitonic\IexCloudSdk\Contracts\IEXCloud;
6
use Digitonic\IexCloudSdk\Exceptions\WrongData;
7
use Digitonic\IexCloudSdk\Requests\BaseGet;
8
9 View Code Duplication
class Tops extends BaseGet
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 = 'tops?symbols={symbols}';
12
13
    protected $symbols;
14
15
    /**
16
     * Create constructor.
17
     *
18
     * @param  IEXCloud  $api
19
     */
20 3
    public function __construct(IEXCloud $api)
21
    {
22 3
        parent::__construct($api);
23 3
    }
24
25
    /**
26
     * @param  mixed  ...$symbols
27
     *
28
     * @return Tops
29
     */
30 1
    public function setSymbols(...$symbols): self
31
    {
32 1
        $this->symbols = implode(',', $symbols);
33
34 1
        return $this;
35
    }
36
37
    /**
38
     * @return string
39
     */
40 1
    protected function getFullEndpoint(): string
41
    {
42 1
        return str_replace('{symbols}', $this->symbols, self::ENDPOINT);
43
    }
44
45
    /**
46
     * @return bool|void
47
     */
48 2
    protected function validateParams(): void
49
    {
50 2
        if (empty($this->symbols)) {
51 1
            throw WrongData::invalidValuesProvided('Please provide symbol(s) to query!');
52
        }
53 1
    }
54
}
55