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

GetRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 2
b 0
f 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 11 1
A buildRequestParams() 0 3 1
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