RiskLimitsResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 33
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCursor() 0 3 1
A __construct() 0 12 2
A getRiskLimitList() 0 3 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Response;
4
5
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
6
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
7
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
8
use Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Interfaces\IRiskLimitsResponseInterface;
9
use Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Interfaces\IRiskLimitsResponseItemInterface;
10
11
class RiskLimitsResponse extends AbstractResponse implements IRiskLimitsResponseInterface
12
{
13
    /**
14
     * Cursor. Use the nextPageCursor token from the response to retrieve the next page of the result set
15
     * @var string
16
     */
17
    private string $cursor;
18
19
    /** @var IRiskLimitsResponseItemInterface[] */
20
    private EntityCollection $list;
21
22
    public function __construct(array $data)
23
    {
24
        $list = new EntityCollection();
25
26
        if (!empty($data['list'])) {
27
            array_map(function ($item) use ($list) {
28
                $list->push(ResponseDtoBuilder::make(RiskLimitsResponseItem::class, $item));
29
            }, $data['list']);
30
        }
31
32
        $this->cursor = $data['nextPageCursor'];
33
        $this->list = $list;
0 ignored issues
show
Documentation Bug introduced by
It seems like $list of type Carpenstar\ByBitAPI\Core...ection\EntityCollection is incompatible with the declared type Carpenstar\ByBitAPI\Deri...ResponseItemInterface[] of property $list.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
    }
35
36
    public function getRiskLimitList(): array
37
    {
38
        return $this->list->all();
39
    }
40
41
    public function getCursor(string $cursor): ?string
42
    {
43
        return $this->cursor;
44
    }
45
}
46