Total Complexity | 7 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class KlineResponse extends AbstractResponse |
||
11 | { |
||
12 | private string $topic; |
||
13 | private string $type; |
||
14 | private \DateTime $timestamp; |
||
15 | private ICollectionInterface $data; |
||
16 | |||
17 | public function __construct(array $data) |
||
18 | { |
||
19 | $collection = new EntityCollection(); |
||
20 | |||
21 | $this->topic = $data['topic']; |
||
22 | $this->type = $data['type']; |
||
23 | $this->timestamp = DateTimeHelper::makeFromTimestamp($data['ts']); |
||
24 | |||
25 | if (!empty($data['data'])) { |
||
26 | if (!empty($data['data'])) { |
||
27 | array_map(function ($item) use ($collection) { |
||
28 | $collection->push(ResponseDtoBuilder::make(KlineResponseItem::class, $item)); |
||
29 | }, $data['data']); |
||
30 | } |
||
31 | } |
||
32 | $this->data = $collection; |
||
33 | } |
||
34 | |||
35 | public function getTopic(): string |
||
36 | { |
||
37 | return $this->topic; |
||
38 | } |
||
39 | |||
40 | public function getType(): string |
||
41 | { |
||
42 | return $this->type; |
||
43 | } |
||
44 | |||
45 | public function getTimestamp(): \DateTime |
||
46 | { |
||
47 | return $this->timestamp; |
||
48 | } |
||
49 | |||
50 | public function getData(): array |
||
53 | } |
||
54 | } |
||
55 | |||
56 | |||
57 |