OrderBookArgument   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 18
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getTopic() 0 3 1
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