slovocast/app/src/Domain/Entity/Episode/File.php

77 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace Slovocast\Domain\Entity\Episode;
2024-11-14 01:49:15 +00:00
use Slovocast\Domain\Entity as EntityTrait;
/**
2024-11-14 02:10:47 +00:00
* Represents the data about the specific file that is used for the episode.
*/
class File
{
2024-11-14 01:49:15 +00:00
use EntityTrait;
/**
* We should also be able to buffer the raw binary data of the buffer to
* the class. Fuck it, we ball.
*/
2024-11-14 01:49:15 +00:00
private string $buffer = "";
public function __construct(
private string $url,
private int $length,
private string $type
) { }
public function getUrl(): string
{
return $this->url;
}
public function getLength(): int
{
return $this->length;
}
public function getType(): string
{
return $this->type;
}
2024-11-14 01:49:15 +00:00
public function setBuffer(string $buffer): void
{
$this->buffer = $buffer;
}
public function getBuffer(): string
{
return $this->buffer;
}
/**
* @param array $props Properties and their values.
*/
public static function fromArray(array $props): File
{
$file = new self(
$props['url'],
(int) $props['length'],
$props['type']
);
if ($props['id']) {
$file->setId($props['id']);
}
if ($props['createAt']) {
$file->setCreatedAt($props['createdAt']);
}
if ($props['updatedAt']) {
$file->setUpdatedAt($props['updatedAt']);
}
return $file;
}
}