KlineArgument   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 getTopic() 0 3 1
A __construct() 0 9 2
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
}