Passed
Push — master ( f1392d...ef746c )
by Steven
56s queued 11s
created

Trades::getFullEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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