WalletBalanceResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBalance() 0 3 1
A __construct() 0 11 2
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Spot\Account\WalletBalance\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\Account\WalletBalance\Interfaces\IWalletBalanceResponseInterfaces;
9
10
class WalletBalanceResponse extends AbstractResponse implements IWalletBalanceResponseInterfaces
11
{
12
    /** @var WalletBalanceResponseItem[] $balance */
13
    private EntityCollection $balance;
14
15
    public function __construct(array $data)
16
    {
17
        $balance = new EntityCollection();
18
19
        if (!empty($data['balances'])) {
20
            array_map(function ($item) use ($balance) {
21
                $balance->push(ResponseDtoBuilder::make(WalletBalanceResponseItem::class, $item));
22
            }, $data['balances']);
23
        }
24
25
        $this->balance = $balance;
0 ignored issues
show
Documentation Bug introduced by
It seems like $balance of type Carpenstar\ByBitAPI\Core...ection\EntityCollection is incompatible with the declared type Carpenstar\ByBitAPI\Spot...etBalanceResponseItem[] of property $balance.

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...
26
    }
27
28
    public function getBalance(): array
29
    {
30
        return $this->balance->all();
31
    }
32
}
33