WebSocketsBuilder::make()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 4
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Core\Builders;
4
5
use Carpenstar\ByBitAPI\Core\Auth\Credentials;
6
use Carpenstar\ByBitAPI\Core\Interfaces\IFabricInterface;
7
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseHandlerInterface;
8
use Carpenstar\ByBitAPI\Core\Interfaces\IWebSocketArgumentInterface;
9
use Carpenstar\ByBitAPI\Core\Interfaces\IWebSocketsChannelInterface;
10
use Carpenstar\ByBitAPI\Core\Objects\WebSockets\Channels\ChannelHandler;
11
12
class WebSocketsBuilder implements IFabricInterface
13
{
14
    public static function make(string $className, IWebSocketArgumentInterface $arguments = null, Credentials $credentials = null, ChannelHandler $callback = null): IWebSocketsChannelInterface
15
    {
16
        if (!in_array(IWebSocketsChannelInterface::class, class_implements($className))) {
17
            throw new \Exception("This websocket-channel {$className} must implement the interface " . IResponseHandlerInterface::class . "!");
18
        }
19
20
        return new $className($arguments, $credentials, $callback);
21
    }
22
}
23