Passed
Push — master ( 8ca73d...2eaf19 )
by Vladislav
02:37 queued 15s
created

LiquidationResponse::getTopic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace Carpenstar\ByBitAPI\WebSockets\Derivatives\PublicChannels\Liquidation\Entity;
3
4
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
5
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
6
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
7
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
8
use Carpenstar\ByBitAPI\WebSockets\Spot\PublicChannels\OrderBook\Entities\OrderBookPriceAbstract;
0 ignored issues
show
Bug introduced by
The type Carpenstar\ByBitAPI\WebS...\OrderBookPriceAbstract was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class LiquidationResponse extends AbstractResponse
11
{
12
    private string $topic;
13
    private string $type;
14
    private \DateTime $timestamp;
15
    private EntityCollection $data;
16
17
    public function __construct(array $data)
18
    {
19
        $collection = new EntityCollection();
20
21
        $this->topic = $data['topic'];
22
        $this->type = $data['type'];
23
        $this->timestamp = DateTimeHelper::makeFromTimestamp($data['ts']);
24
25
        if (!empty($data['data'])) {
26
            
27
            $data['data'] = array_is_list($data['data']) ? $data['data'] : [$data['data']];
0 ignored issues
show
Bug introduced by
The function array_is_list was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
            $data['data'] = /** @scrutinizer ignore-call */ array_is_list($data['data']) ? $data['data'] : [$data['data']];
Loading history...
28
29
            array_map(function ($item) use ($collection) {
30
                $collection->push(ResponseDtoBuilder::make(OrderBookPriceAbstract::class, $item));
31
            }, $data['data']);
32
        }
33
34
        $this->data = $collection;
35
    }
36
37
    public function getTopic(): string
38
    {
39
        return $this->topic;
40
    }
41
42
    public function getType(): string
43
    {
44
        return $this->type;
45
    }
46
47
    public function getData(): ?array
48
    {
49
        return $this->data->all();
50
    }
51
}
52