GetOrderListResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 51
rs 10
c 2
b 0
f 0
wmc 5

4 Methods

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