Api::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Codenixsv\BitfinexApi\Api;
6
7
use Codenixsv\BitfinexApi\Message\ResponseTransformer;
8
use Exception;
9
use GuzzleHttp\Client;
10
11
/**
12
 * Class Api
13
 * @package Codenixsv\BitfinexApi\Api
14
 */
15
class Api
16
{
17
    /** @var Client */
18
    protected $client;
19
20
    /** @var string */
21
    private $version = 'v2';
22
23
    /** @var ResponseTransformer */
24
    protected $transformer;
25
26
    /**
27
     * Api constructor.
28
     * @param Client $client
29
     */
30 12
    public function __construct(Client $client)
31
    {
32 12
        $this->client = $client;
33 12
        $this->transformer = new ResponseTransformer();
34 12
    }
35
36
    /**
37
     * @param string $uri
38
     * @param array $query
39
     * @return array
40
     * @throws Exception
41
     */
42 11
    public function get(string $uri, array $query = []): array
43
    {
44 11
        $response = $this->client->request('GET', '/' . $this->version
45 11
            . $uri, ['query' => $query]);
46
47 11
        return $this->transformer->transform($response);
48
    }
49
}
50