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

DataPoints::validateParams()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0625
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\BaseRequest;
8
9 View Code Duplication
class DataPoints 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 = 'data-points/{symbol}/{key}';
12
13
    /**
14
     * @var string
15
     */
16
    protected $key = '';
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  string  $key
30
     *
31
     * @return DataPoints
32
     */
33
    public function setKey(string $key): self
34
    {
35
        $this->key = $key;
36
37
        return $this;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    protected function getFullEndpoint(): string
44
    {
45
        return str_replace(
46
            '{symbol}',
47
            $this->symbol,
48
            str_replace(
49
                '{key}',
50
                $this->key,
51
                self::ENDPOINT
52
            )
53
        );
54
    }
55
56 1
    protected function validateParams()
57
    {
58 1
        if (empty($this->symbol)) {
59 1
            throw WrongData::invalidValuesProvided('Please provide a symbol to query!');
60
        }
61
    }
62
}
63