Api   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 31
ccs 9
cts 9
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 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Codenixsv\CoinGeckoApi\Api;
6
7
use Codenixsv\CoinGeckoApi\CoinGeckoClient;
8
use Codenixsv\CoinGeckoApi\Message\ResponseTransformer;
9
use Exception;
10
11
class Api
12
{
13
    /** @var CoinGeckoClient */
14
    protected $client;
15
16
    private $version = 'v3';
17
18
    /** @var ResponseTransformer */
19
    protected $transformer;
20
21 48
    public function __construct(CoinGeckoClient $client)
22
    {
23 48
        $this->client = $client;
24 48
        $this->transformer = new ResponseTransformer();
25 48
    }
26
27
    /**
28
     * @param string $uri
29
     * @param array $query
30
     * @return array
31
     * @throws Exception
32
     */
33 37
    public function get(string $uri, array $query = []): array
34
    {
35 37
        $response = $this->client->getHttpClient()->request('GET', '/api/' . $this->version
36 37
            . $uri, ['query' => $query]);
37 37
        $this->client->setLastResponse($response);
38
39 37
        return $this->transformer->transform($response);
40
    }
41
}
42