Endpoint::authenticationData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
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