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

KlineArgument::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 9
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
}