Add the episode repository
This commit is contained in:
parent
4f94b80902
commit
7aa1d64994
@ -2,11 +2,17 @@
|
|||||||
|
|
||||||
namespace Slovocast\Domain\Entity\Episode;
|
namespace Slovocast\Domain\Entity\Episode;
|
||||||
|
|
||||||
|
use Slovocast\Domain\Entity as EntityTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the file for the episode itself.
|
* Represents the file for the episode itself.
|
||||||
*/
|
*/
|
||||||
class File
|
class File
|
||||||
{
|
{
|
||||||
|
use EntityTrait;
|
||||||
|
|
||||||
|
private string $buffer = "";
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $url,
|
private string $url,
|
||||||
private int $length,
|
private int $length,
|
||||||
@ -27,4 +33,40 @@ class File
|
|||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Slovocast\Domain\Repository\Episode;
|
||||||
|
|
||||||
|
use Slovocast\Domain\Entity\Episode;
|
||||||
|
use Slovocast\Domain\Entity\Episode\File;
|
||||||
|
use Slovocast\Domain\RepositoryInterface;
|
||||||
|
|
||||||
|
interface EpisodeFileRepositoryInterface extends RepositoryInterface
|
||||||
|
{
|
||||||
|
public function get(string $location): File;
|
||||||
|
public function getFromEpisode(Episode $episode): File;
|
||||||
|
public function create(File $file): File;
|
||||||
|
public function update(File $file): bool;
|
||||||
|
public function delete(File $file): bool;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user