play-code-live/vkplay-live-sdk

View on GitHub
src/DTO/ChannelDTO.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

declare(strict_types=1);

namespace PlayCode\VKPlayLiveSDK\DTO;

class ChannelDTO
{
    public function __construct(
        public readonly ChannelInfoDTO $channelInfo,
        public readonly OwnerDTO $owner,
        public readonly StreamInfoDTO $streamInfo,
    )
    {
    }

    public static function fromArray(array $data): self
    {
        return new self(
            ChannelInfoDTO::fromArray($data['channel'] ?? []),
            OwnerDTO::fromArray($data['owner'] ?? []),
            StreamInfoDTO::fromArray($data['stream'] ?? [])
        );
    }
}