AllAssetInfoResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 21
rs 10
c 3
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAssets() 0 3 1
A __construct() 0 11 2
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Spot\LeverageToken\AllAssetInfo\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\Spot\LeverageToken\AllAssetInfo\Interfaces\IAllAssetInfoResponseInterface;
9
use Carpenstar\ByBitAPI\Spot\LeverageToken\AllAssetInfo\Interfaces\IAllAssetInfoResponseItemInterface;
10
11
class AllAssetInfoResponse extends AbstractResponse implements IAllAssetInfoResponseInterface
12
{
13
    /** @var IAllAssetInfoResponseItemInterface $list */
14
    private EntityCollection $list;
15
16
    public function __construct(array $data)
17
    {
18
        $list = new EntityCollection();
19
20
        if (!empty($data['list'])) {
21
            array_map(function ($item) use ($list) {
22
                $list->push(ResponseDtoBuilder::make(AllAssetInfoResponseItem::class, $item));
23
            }, $data['list']);
24
        }
25
26
        $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\Spot...foResponseItemInterface 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...
27
    }
28
29
    public function getAssets(): array
30
    {
31
        return $this->list->all();
32
    }
33
}
34