Passed
Push — master ( d88bb3...f13907 )
by Steven
01:04
created

BaseGet::validateParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
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\Requests;
4
5
use Digitonic\IexCloudSdk\Contracts\IEXCloud;
6
use GuzzleHttp\Psr7\Request;
7
use Illuminate\Support\Collection;
8
9
class BaseGet
10
{
11
    const ENDPOINT = '';
12
13
    protected $method = 'GET';
14
15
    protected $api;
16
17
    /**
18
     * Create constructor.
19
     *
20
     * @param  IEXCloud  $api
21
     */
22 20
    public function __construct(IEXCloud $api)
23
    {
24 20
        $this->api = $api;
25 20
    }
26
27
    /**
28
     * @return Collection
29
     */
30 13
    public function send(): Collection
31
    {
32 13
        $this->validateParams();
33
34 10
        $request = new Request($this->method, $this->getFullEndpoint());
35
36 10
        $response = $this->api->send($request);
37
38 10
        return collect(json_decode($response->getBody()->getContents()));
39
    }
40
41
    /**
42
     * @return string
43
     */
44 6
    protected function getFullEndpoint(): string
45
    {
46 6
        return self::ENDPOINT;
47
    }
48
49
    /**
50
     * @return bool
51
     */
52 7
    protected function validateParams()
53
    {
54 7
        return true;
55
    }
56
}
57