From 7aa1d64994aa9a23cf76c03b1eab3f7101c86659 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Thu, 14 Nov 2024 01:49:15 +0000 Subject: [PATCH] Add the episode repository --- app/src/Domain/Entity/Episode/File.php | 42 +++++++++++++++++++ .../EpisodeFileRepositoryInterface.php | 16 +++++++ 2 files changed, 58 insertions(+) create mode 100644 app/src/Domain/Repository/Episode/EpisodeFileRepositoryInterface.php diff --git a/app/src/Domain/Entity/Episode/File.php b/app/src/Domain/Entity/Episode/File.php index 2e980eb..9630a03 100644 --- a/app/src/Domain/Entity/Episode/File.php +++ b/app/src/Domain/Entity/Episode/File.php @@ -2,11 +2,17 @@ namespace Slovocast\Domain\Entity\Episode; +use Slovocast\Domain\Entity as EntityTrait; + /** * Represents the file for the episode itself. */ class File { + use EntityTrait; + + private string $buffer = ""; + public function __construct( private string $url, private int $length, @@ -27,4 +33,40 @@ class File { 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; + } } diff --git a/app/src/Domain/Repository/Episode/EpisodeFileRepositoryInterface.php b/app/src/Domain/Repository/Episode/EpisodeFileRepositoryInterface.php new file mode 100644 index 0000000..7838747 --- /dev/null +++ b/app/src/Domain/Repository/Episode/EpisodeFileRepositoryInterface.php @@ -0,0 +1,16 @@ +