for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Carpenstar\ByBitAPI\WebSockets\Derivatives\PublicChannels\PublicTrade\Entities;
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
use Carpenstar\ByBitAPI\Core\Interfaces\ICollectionInterface;
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
class PublicTradeResponse extends AbstractResponse
{
private string $topic;
private string $type;
private \DateTime $createdAt;
private ICollectionInterface $data;
public function __construct(array $data)
$collection = new EntityCollection();
$this->topic = $data['topic'];
$this->type = $data['type'];
$this->createdAt = DateTimeHelper::makeFromTimestamp($data['ts']);
if (!empty($data['data'])) {
array_map(function ($item) use ($collection) {
$collection->push(ResponseDtoBuilder::make(PublicTradeResponseItem::class, $item));
}, $data['data']);
}
$this->data = $collection;
public function getTopic(): string
return $this->topic;
public function getType(): string
return $this->type;
public function getCreatedAt(): \DateTime
return $this->createdAt;
public function getData(): array
return $this->data->all();