Passed
Push — master ( 80a2af...b754d5 )
by Fabian
51s
created

GetRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author  Fabian Hanisch
4
 * @since   16.07.2017 02:40
5
 * @version 1.0
6
 */
7
8
namespace HanischIt\KrakenApi\Service\RequestService;
9
10
use HanischIt\KrakenApi\Enum\RequestMethodEnum;
11
use HanischIt\KrakenApi\External\HttpClient;
12
use HanischIt\KrakenApi\Model\RequestInterface;
13
use HanischIt\KrakenApi\Model\RequestOptions;
14
use HanischIt\KrakenApi\Model\ResponseInterface;
15
16
/**
17
 * Class PostRequest
18
 *
19
 * @package HanischIt\KrakenApi\Service\RequestService
20
 */
21
class GetRequest
22
{
23
    /**
24
     * @var HttpClient
25
     */
26
    private $client;
27
    /**
28
     * @var RequestHeader
29
     */
30
    private $requestHeader;
31
32
    /**
33
     * Request constructor.
34
     *
35
     * @param HttpClient $client
36
     * @param RequestHeader $requestHeader
37
     */
38 22
    public function __construct(HttpClient $client, RequestHeader $requestHeader)
39
    {
40 22
        $this->client = $client;
41 22
        $this->requestHeader = $requestHeader;
42 22
    }
43
44
    /**
45
     * @param RequestInterface $request
46
     * @param RequestOptions $requestOptions
47
     *
48
     * @return ResponseInterface
49
     */
50 1
    public function execute(RequestInterface $request, RequestOptions $requestOptions)
51
    {
52 1
        $path = $requestOptions->getEndpoint() . "/" . $requestOptions->getVersion() . "/public/" . $request->getMethod();
53
54 1
        return $this->client->request(RequestMethodEnum::REQUEST_METHOD_GET, $path, [
55 1
            'query' => $request->getRequestData()
56 1
        ]);
57
    }
58
}
59