GetClosedPnLResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 38
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
A getClosedPnlList() 0 3 1
A getNextPageCursor() 0 3 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\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\Contract\Position\GetClosedPnL\Interfaces\IGetClosedPnLResponseInterface;
9
use Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Interfaces\IGetClosedPnLResponseItemInterface;
10
11
class GetClosedPnLResponse extends AbstractResponse implements IGetClosedPnLResponseInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private string $nextPageCursor;
17
18
    /**
19
     * @var IGetClosedPnLResponseItemInterface[]
20
     */
21
    private EntityCollection $list;
22
23
    public function __construct(array $data)
24
    {
25
        $this->nextPageCursor = $data['nextPageCursor'];
26
27
        $list = new EntityCollection();
28
29
        if (!empty($data['list'])) {
30
            array_map(function ($item) use ($list) {
31
                $list->push(ResponseDtoBuilder::make(GetClosedPnLResponseItem::class, $item));
32
            }, $data['list']);
33
        }
34
35
        $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...
36
    }
37
38
    /**
39
     * @return IGetClosedPnLResponseItemInterface[]
40
     */
41
    public function getClosedPnlList(): array
42
    {
43
        return $this->list->all();
44
    }
45
46
    public function getNextPageCursor(): string
47
    {
48
        return $this->nextPageCursor;
49
    }
50
}
51