Passed
Push — master ( 3894cc...b6588e )
by Vladislav
06:30 queued 04:28
created

WebSocketsBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 7 2
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