Passed
Push — master ( 62ad78...936fc5 )
by Steven
01:52 queued 11s
created

DelayedQuote::oddLot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Digitonic\IexCloudSdk\Stocks;
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 DelayedQuote 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 = 'stock/{symbol}/delayed-quote';
12
13
    /**
14
     * @var bool
15
     */
16
    protected $oddLot = false;
17
18
    /**
19
     * Create constructor.
20
     *
21
     * @param  IEXCloud  $api
22
     */
23 3
    public function __construct(IEXCloud $api)
24
    {
25 3
        parent::__construct($api);
26 3
    }
27
28
    /**
29
     * If the oddLot property is set, add it to the end of the endpoint string.
30
     *
31
     * @return string
32
     */
33 1
    protected function getFullEndpoint(): string
34
    {
35 1
        $endpoint = str_replace('{symbol}', $this->symbol, self::ENDPOINT);
36
37 1
        return $this->oddLot ? "$endpoint/oddLot=$this->oddLot" : $endpoint;
38
    }
39
40
    /**
41
     * @return bool|void
42
     * @throws WrongData
43
     */
44 2
    protected function validateParams(): void
45
    {
46 2
        if (empty($this->symbol)) {
47 1
            throw WrongData::invalidValuesProvided('Please provide a symbol to query!');
48
        }
49 1
    }
50
51
    public function oddLot(bool $oddLot = true): self
52
    {
53
        $this->oddLot = $oddLot;
54
55
        return $this;
56
    }
57
}
58