Completed
Push — master ( aa3009...686c2f )
by Mikhail
02:10
created

Api   A

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 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

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