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

Generic::validateParams()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace Digitonic\IexCloudSdk\Requests;
4
5
use Digitonic\IexCloudSdk\Contracts\IEXCloud;
6
7
class Generic extends BaseRequest
8
{
9
    private $endpoint = '';
10
    private $params   = '';
11
12
    /**
13
     * Create constructor.
14
     *
15
     * @param  IEXCloud  $api
16
     */
17
    public function __construct(IEXCloud $api)
18
    {
19
        parent::__construct($api);
20
    }
21
22
    /**
23
     * @return string
24
     */
25
    protected function getFullEndpoint(): string
26
    {
27
        return $this->endpoint . ($this->params ? '?' . http_build_query($this->params) : '');
28
    }
29
30
    /**
31
     * @return bool|void
32
     */
33
    protected function validateParams(): void
34
    {
35
        if (empty($this->endpoint)) {
36
            throw WrongData::invalidValuesProvided('Please provide endpoint!');
37
        }
38
    }
39
40
    /**
41
     * Set endpoint
42
     *
43
     * @param $endpoint
44
     * @return Generic
45
     */
46
    public function setEndpoint($endpoint) {
47
        $this->endpoint = $endpoint;
48
        return $this;
49
    }
50
51
    /**
52
     * Set params
53
     *
54
     * @param $params
55
     * @return Generic
56
     */
57
    public function setParams(array $params = []) {
58
        $this->params = $params;
0 ignored issues
show
Documentation Bug introduced by
It seems like $params of type array is incompatible with the declared type string of property $params.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
59
        return $this;
60
    }
61
}
62