ResponseDtoBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
c 0
b 0
f 0
dl 0
loc 15
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\Interfaces\IFabricInterface;
6
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseDataInterface;
7
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseHandlerInterface;
8
9
class ResponseDtoBuilder implements IFabricInterface
10
{
11
    /**
12
     * @param string $className
13
     * @param array|null $data
14
     * @return IResponseDataInterface
15
     * @throws \Exception
16
     */
17
    public static function make(string $className, ?array $data = null): IResponseDataInterface
18
    {
19
        if (!in_array(IResponseDataInterface::class, class_implements($className))) {
20
            throw new \Exception("That DTO {$className} must be implements the interface " . IResponseHandlerInterface::class . "!");
21
        }
22
23
        return new $className($data);
24
    }
25
}
26