Passed
Push — master ( a67e0e...5a6b87 )
by Vladislav
09:14 queued 07:10
created

GetRequest::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Core\Request;
4
5
use Carpenstar\ByBitAPI\Core\Enums\EnumHttpMethods;
6
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseHandlerInterface;
7
8
class GetRequest extends Curl
9
{
10
    /**
11
     * @param string $endpoint
12
     * @param array $queryParams
13
     * @return IResponseHandlerInterface
14
     */
15
    public function execute(string $endpoint, array $queryParams): array
16
    {
17
        $queryString = $this->buildRequestParams($queryParams);
18
19
        $this->addCurlOpt(CURLOPT_URL, $this->credentials->getHost() . $endpoint . '?' . $queryString)
20
             ->addCurlOpt(CURLOPT_CUSTOMREQUEST, EnumHttpMethods::GET);
21
22
        $this->auth($queryString);
23
24
25
        return $this->query();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->query() returns the type array which is incompatible with the documented return type Carpenstar\ByBitAPI\Core...esponseHandlerInterface.
Loading history...
26
    }
27
28
    /**
29
     * @param array $queryParams
30
     * @return string
31
     */
32
    private function buildRequestParams(array $queryParams): ?string
33
    {
34
        return http_build_query($queryParams);
35
    }
36
}
37