Passed
Push — master ( 4e067f...6d118b )
by Vladymyr
03:42
created

Api   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 33
ccs 8
cts 8
cp 1
rs 10

2 Methods

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