Endpoint   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 4 1
A getHeaders() 0 6 1
A authenticationData() 0 12 1
1
<?php
2
3
namespace CryptoMarkets\Binance\Endpoints;
4
5
use CryptoMarkets\Common\Endpoint as BaseEndpoint;
6
7
abstract class Endpoint extends BaseEndpoint
8
{
9
    /**
10
     * Get the request url.
11
     *
12
     * @return string
13
     */
14
    public function getUrl()
15
    {
16
        return 'https://api.binance.com/api/';
17
    }
18
19
    /**
20
     * Get the request headers.
21
     *
22
     * @return array
23
     */
24
    public function getHeaders()
25
    {
26
        return array_replace(parent::getHeaders(), [
27
            'X-MBX-APIKEY' => $this->params['api_key'],
28
        ]);
29
    }
30
31
    /**
32
     * Get the authentication request data.
33
     *
34
     * @return array
35
     */
36
    protected function authenticationData()
37
    {
38
        $params = $this->getData();
39
40
        $params['timestamp'] = number_format(microtime(true) * 1000, 0, '.', '');
41
42
        $query = http_build_query($params, '', '&');
43
44
        $params['signature'] = hash_hmac('sha256', $query, $this->params['secret']);
45
46
        return $params;
47
    }
48
}
49