for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Carpenstar\ByBitAPI\WebSockets\Spot\PublicChannels\Kline\Entities;
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
class KlineResponse extends AbstractResponse
{
/**
* Topic name
* @var string $topic
*/
private string $topic;
* The timestamp that message is sent out
* @var \DateTime $requestTimestamp
private \DateTime $requestTimestamp;
* Data type. snapshot
* @var string $type
private string $type;
private EntityCollection $data;
public function __construct(array $data)
$collection = new EntityCollection();
$this->requestTimestamp = DateTimeHelper::makeFromTimestamp($data['ts']);
$this->topic = $data['topic'];
$this->type = $data['type'];
if (!empty($data['data'])) {
$data['data'] = isset($data['data'][0]) ? $data['data'] : [$data['data']];
array_map(function ($item) use ($collection) {
$collection->push(ResponseDtoBuilder::make(KlineResponseItem::class, $item));
}, $data['data']);
}
$this->data = $collection;
public function getTopic(): string
return $this->topic;
public function getRequestTimestamp(): \DateTime
return $this->requestTimestamp;
public function getType(): string
return $this->type;
public function getData(): array
return $this->data->all();