Passed
Pull Request — master (#1)
by Steven
01:33
created

DataPoints::setSymbol()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Digitonic\IexCloudSdk\DataApis;
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 DataPoints 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 = 'data-points/{symbol}/{key}';
12
13
    /**
14
     * @var string
15
     */
16
    protected $symbol = '';
17
18
    /**
19
     * @var string
20
     */
21
    protected $key = '';
22
23
    /**
24
     * Create constructor.
25
     *
26
     * @param  IEXCloud  $api
27
     */
28 4
    public function __construct(IEXCloud $api)
29
    {
30 4
        parent::__construct($api);
31 4
    }
32
33
    /**
34
     * @param  string  $symbol
35
     *
36
     * @return DataPoints
37
     */
38 2
    public function setSymbol(string $symbol): self
39
    {
40 2
        $this->symbol = $symbol;
41
42 2
        return $this;
43
    }
44
45
    /**
46
     * @param  string  $key
47
     *
48
     * @return DataPoints
49
     */
50 1
    public function setKey(string $key): self
51
    {
52 1
        $this->key = $key;
53
54 1
        return $this;
55
    }
56
57
    /**
58
     * @return string
59
     */
60 2
    protected function getFullEndpoint(): string
61
    {
62 2
        return str_replace(
63 2
            '{symbol}',
64 2
            $this->symbol,
65 2
            str_replace(
66 2
                '{key}',
67 2
                $this->key,
68 2
                self::ENDPOINT
69
            )
70
        );
71
    }
72
73 3
    protected function validateParams()
74
    {
75 3
        if (empty($this->symbol)) {
76 1
            throw WrongData::invalidValuesProvided('Please provide a symbol to query!');
77
        }
78 2
    }
79
}
80