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

KlineArgument   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
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\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
}