2024-11-12 03:29:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Slovocast\Domain\Entity\Episode;
|
|
|
|
|
2024-11-14 01:49:15 +00:00
|
|
|
use Slovocast\Domain\Entity as EntityTrait;
|
|
|
|
|
2024-11-12 03:29:24 +00:00
|
|
|
/**
|
2024-11-14 02:10:47 +00:00
|
|
|
* Represents the data about the specific file that is used for the episode.
|
2024-11-12 03:29:24 +00:00
|
|
|
*/
|
|
|
|
class File
|
|
|
|
{
|
2024-11-14 01:49:15 +00:00
|
|
|
use EntityTrait;
|
|
|
|
|
|
|
|
private string $buffer = "";
|
|
|
|
|
2024-11-12 03:29:24 +00:00
|
|
|
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;
|
|
|
|
}
|
2024-11-12 03:29:24 +00:00
|
|
|
}
|