KlineArgument::__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 2
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Carpenstar\ByBitAPI\WebSockets\Derivatives\PublicChannels\Kline\Argument;
4
5
use Carpenstar\ByBitAPI\Core\Enums\WebSocketTopicNameEnum;
6
use Carpenstar\ByBitAPI\Core\Objects\WebSockets\WebSocketArgument;
7
use Carpenstar\ByBitAPI\Core\Enums\WebSocketDerivativesIntervalEnum;
8
9
class KlineArgument extends WebSocketArgument
10
{
11
    private string $interval;
12
13
    public function __construct(string $symbol, int $interval)
14
    {
15
        parent::__construct($symbol);
16
17
        if (!in_array($interval, WebSocketDerivativesIntervalEnum::ALL)) {
18
            throw new \Exception("Invalid interval {$interval} specified. See the list of available intervals in the file: " . WebSocketDerivativesIntervalEnum::class);
19
        }
20
21
        $this->interval = $interval;
22
    }
23
24
    public function getTopic(): array
25
    {
26
        return [WebSocketTopicNameEnum::DERIVATIVES_KLINE.".{$this->interval}.{$this->getSymbols()}"];
27
    }
28
}