From af1341fd4a0dff7bc4f0b4d00f4e8fccb86ba4c6 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Mon, 11 Nov 2024 20:51:00 -0500 Subject: [PATCH] Add the transaction entity and the episodes directory --- .../20240627230956_create_episodes_table.php | 1 + app/src/Domain/Entity/Episode.php | 38 ++++++++++++++++++- app/src/Domain/Entity/Transaction.php | 31 +++++++++++++++ .../Episode/EpisodeRepositoryInterface.php | 21 ++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 app/src/Domain/Entity/Transaction.php create mode 100644 app/src/Domain/Repository/Episode/EpisodeRepositoryInterface.php diff --git a/app/db/migrations/20240627230956_create_episodes_table.php b/app/db/migrations/20240627230956_create_episodes_table.php index f59c956..92fa751 100644 --- a/app/db/migrations/20240627230956_create_episodes_table.php +++ b/app/db/migrations/20240627230956_create_episodes_table.php @@ -50,6 +50,7 @@ final class CreateEpisodesTable extends AbstractMigration ->addColumn('length', 'integer', [ 'signed' => false ]) ->addColumn('description', 'text') ->addColumn('explicit', 'boolean', [ 'default' => false ]) + ->addColumn('serial_number', 'integer', [ 'signed' => false ]) ->addColumn('channel_id', 'integer', [ 'signed' => false, 'null' => false diff --git a/app/src/Domain/Entity/Episode.php b/app/src/Domain/Entity/Episode.php index 573f941..7635ce2 100644 --- a/app/src/Domain/Entity/Episode.php +++ b/app/src/Domain/Entity/Episode.php @@ -2,6 +2,7 @@ namespace Slovocast\Domain\Entity; +use DateTimeImmutable; use Slovocast\Domain\Entity as EntityTrait; class Episode @@ -15,15 +16,48 @@ class Episode private string $link, private int $length, private string $description, - private bool $explicit = false, + private int $serialNumber, + private bool $explicit, + private DateTimeImmutable $publishedDate, + private string $episodeType, ) { $this->duration = $this->parseDuration($this->length); } + public function getTitle(): string + { + return $this->title; + } + + public function getLink(): string + { + return $this->link; + } + + public function getLength(): int + { + return $this->length; + } + + public function getDuration(): string + { + return $this->duration; + } + + public function getSerialNumber(): int + { + return $this->serialNumber; + } + + public function isExplicit(): bool + { + return $this->explicit; + } + /** * @TODO Figure out how to parse second to HH:MM:SS */ - protected function parseDuration(int $length): string + public static function parseDuration(int $length): string { $hours = floor($length / 3600); $minutes = floor($length / 60) % 60; diff --git a/app/src/Domain/Entity/Transaction.php b/app/src/Domain/Entity/Transaction.php new file mode 100644 index 0000000..486fc40 --- /dev/null +++ b/app/src/Domain/Entity/Transaction.php @@ -0,0 +1,31 @@ +code; + } + + public function getType(): string + { + return $this->type; + } + + public function getTotal(): int + { + return $this->total; + } +} diff --git a/app/src/Domain/Repository/Episode/EpisodeRepositoryInterface.php b/app/src/Domain/Repository/Episode/EpisodeRepositoryInterface.php new file mode 100644 index 0000000..d6862c5 --- /dev/null +++ b/app/src/Domain/Repository/Episode/EpisodeRepositoryInterface.php @@ -0,0 +1,21 @@ +