OrderBookArgument::getTopic()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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