Api   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 35
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A get() 0 7 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