Test Failed
Pull Request — master (#20)
by Vladislav
02:36
created

GetOrderListResponse::getLeavesValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Response;
3
4
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
5
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
6
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
7
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOpenOrders\Interfaces\IGetOpenOrdersResponseItemInterface;
8
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Interfaces\IGetOrderListResponseInterface;
9
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Interfaces\IGetOrderListResponseItemInterface;
10
11
class GetOrderListResponse extends AbstractResponse implements IGetOrderListResponseInterface
12
{
13
    /**
14
     * Product type
15
     * @var string
16
     */
17
    private string $category;
18
19
    /**
20
     * Cursor. Used to pagination
21
     * @var string
22
     */
23
    private string $nextPageCursor;
24
25
    /**
26
     * @var IGetOrderListResponseItemInterface[]
27
     */
28
    private  $list;
29
30
    public function __construct(array $data)
31
    {
32
        $this->category = $data['category'];
33
        $this->nextPageCursor = $data['nextPageCursor'];
34
35
        $list = new EntityCollection();
36
37
        if (!empty($data['list'])) {
38
            array_map(function ($item) use ($list) {
39
                $list->push(ResponseDtoBuilder::make(GetOrderListResponseItem::class, $item));
40
            }, $data['list']);
41
        }
42
43
        $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...
44
    }
45
46
    /**
47
     * @return IGetOpenOrdersResponseItemInterface[]
48
     */
49
    public function getOrderList(): array
50
    {
51
        return $this->list->all();
52
    }
53
54
    public function getNextPageCursor(): string
55
    {
56
        return $this->nextPageCursor;
57
    }
58
59
    public function getCategory(): string
60
    {
61
        return $this->category;
62
    }
63
}