SubscribeRawBooks::getFrame()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Codenixsv\BitfinexWs\Request;
6
7
use Ratchet\RFC6455\Messaging\Frame;
8
9
/**
10
 * Class SubscribeRawBooks
11
 * @package Codenixsv\BitfinexWs\Request
12
 */
13
class SubscribeRawBooks implements Request
14
{
15
    private const PRECISION = 'P0';
16
17
    /** @var string */
18
    private $symbol;
19
20
    /** @var string */
21
    private $length;
22
23
    /**
24
     * SubscribeRawBooks constructor.
25
     * @param string $symbol
26
     * @param string $length
27
     */
28 3
    public function __construct(string $symbol, string $length)
29
    {
30 3
        $this->symbol = $symbol;
31 3
        $this->length = $length;
32 3
    }
33
34
    /**
35
     * @return array
36
     */
37 3
    public function getPayload(): array
38
    {
39
        return [
40 3
            'event' => 'subscribe',
41 3
            'channel' => 'book',
42 3
            'symbol' => $this->symbol,
43 3
            'prec' => self::PRECISION,
44 3
            'len' => $this->length,
45
46
        ];
47
    }
48
49
    /**
50
     * @return Frame
51
     */
52 2
    public function getFrame(): Frame
53
    {
54 2
        return new Frame(json_encode($this->getPayload()));
55
    }
56
}
57