Completed
Push — master ( 1777e6...510d36 )
by Mikhail
01:24
created

Api::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
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 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 = '/api/';
24
25
    /**
26
     * Api constructor.
27
     * @param Client $client
28
     */
29 23
    public function __construct(Client $client)
30
    {
31 23
        $this->client = $client;
32 23
        $this->transformer = new ResponseTransformer();
33 23
    }
34
35
    /**
36
     * @param string $uri
37
     * @param array $query
38
     * @return array
39
     * @throws Exception
40
     */
41 17 View Code Duplication
    public function get(string $uri, array $query = []): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43 17
        $response = $this->client->request('GET', $this->endpoint . $this->version
44 17
            . $uri, ['query' => $query]);
45
46 17
        return $this->transformer->transform($response);
47
    }
48
49
    /**
50
     * @param string $uri
51
     * @param array $query
52
     * @return array
53
     * @throws Exception
54
     */
55 2 View Code Duplication
    public function post(string $uri, array $query = []): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57 2
        $response = $this->client->request('POST', $this->endpoint . $this->version
58 2
            . $uri, ['query' => $query]);
59
60 2
        return $this->transformer->transform($response);
61
    }
62
63
    /**
64
     * @param string $uri
65
     * @param array $query
66
     * @return array
67
     * @throws Exception
68
     */
69 1 View Code Duplication
    public function delete(string $uri, array $query = []): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
    {
71 1
        $response = $this->client->request('DELETE', $this->endpoint . $this->version
72 1
            . $uri, ['query' => $query]);
73
74 1
        return $this->transformer->transform($response);
75
    }
76
}
77