Trade::mapResponse()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 12
nc 1
nop 1
1
<?php
2
3
namespace CryptoMarkets\Binance\Endpoints;
4
5
class Trade extends Endpoint
6
{
7
    /**
8
     * Get the request url.
9
     *
10
     * @return string
11
     */
12
    public function getUrl()
13
    {
14
        return parent::getUrl().'v1/trades';
15
    }
16
17
    /**
18
     * Get the request method.
19
     *
20
     * @return string
21
     */
22
    public function getMethod()
23
    {
24
        return 'GET';
25
    }
26
27
    /**
28
     * Get the request data.
29
     *
30
     * @return array
31
     */
32 View Code Duplication
    public function getData()
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...
33
    {
34
        return [
35
            'symbol' => $this->params['symbol'] ?? null,
36
            'limit'  => $this->params['limit'] ?? null,
37
        ];
38
    }
39
40
    /**
41
     * Map the given array to create a response object.
42
     *
43
     * @param  array  $data
44
     * @return array
45
     */
46
    public function mapResponse(array $data = [])
47
    {
48
        return array_map(function ($item) {
49
            return [
50
                'id' => $item['id'],
51
                'symbol' => $this->params['symbol'],
52
                'side' => $item['isBuyerMaker'] ? 'buy' : 'sell',
53
                'type' => 'limit',
54
                'status' => 'open',
55
                'price' => $item['price'],
56
                'amount' => $item['qty'],
57
                'timestamp' => $item['time'],
58
            ];
59
        }, $data);
60
    }
61
}
62