Passed
Pull Request — master (#10)
by Vladislav
15:29 queued 07:37
created

KlineArgument::getTopic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

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