OrderBookArgument::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 3
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Carpenstar\ByBitAPI\WebSockets\Derivatives\PublicChannels\OrderBook\Argument;
4
5
use Carpenstar\ByBitAPI\Core\Enums\EnumIntervals;
6
use Carpenstar\ByBitAPI\Core\Enums\WebSocketOrderBookDepth;
7
use Carpenstar\ByBitAPI\Core\Enums\WebSocketTopicNameEnum;
8
use Carpenstar\ByBitAPI\Core\Objects\WebSockets\WebSocketArgument;
9
10
class OrderBookArgument extends WebSocketArgument
11
{
12
    private int $depth;
13
14
    public function __construct(string $symbol, int $depth, ?string $reqId = null)
15
    {
16
        parent::__construct($symbol, $reqId);
17
18
        if (!in_array($depth, WebSocketOrderBookDepth::ALL)) {
19
            throw new \Exception("Invalid interval {$depth} specified. See the list of available intervals in the file: " . EnumIntervals::class);
20
        }
21
22
        $this->depth = $depth;
23
    }
24
25
    public function getTopic(): array
26
    {
27
        return [WebSocketTopicNameEnum::DERIVATIVES_ORDERBOOK.".{$this->depth}.{$this->getSymbols()}"];
28
    }
29
}
30