From 4f94b809020b450693d05ebf4cdd2dd000ea85a1 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Wed, 13 Nov 2024 03:32:48 +0000 Subject: [PATCH] Start the Episode repository. --- app/src/Domain/Entity/Episode.php | 31 +++++++++++++++ .../Repository/Episode/EpisodeRespository.php | 38 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 app/src/Domain/Repository/Episode/EpisodeRespository.php diff --git a/app/src/Domain/Entity/Episode.php b/app/src/Domain/Entity/Episode.php index 7635ce2..8001934 100644 --- a/app/src/Domain/Entity/Episode.php +++ b/app/src/Domain/Entity/Episode.php @@ -65,4 +65,35 @@ class Episode return ""; } + + /** + * @param array $props The properties of the method + */ + public static function fromArray(array $props): self + { + $episode = new self( + $props['title'], + $props['link'], + (int) $props['length'], + $props['description'], + $props['serialNumber'], + (bool) $props['explicit'], + $props['publishedDate'], + $props['episdoeType'] + ); + + if ($props['id']) { + $episode->setId($props['id']); + } + + if ($props['created_at']) { + $episode->setCreatedAt($props['createdAt']); + } + + if ($props['updated_id']) { + $episode->setUpdatedAt($props['updatedAt']); + } + + return $episode; + } } diff --git a/app/src/Domain/Repository/Episode/EpisodeRespository.php b/app/src/Domain/Repository/Episode/EpisodeRespository.php new file mode 100644 index 0000000..1b1a692 --- /dev/null +++ b/app/src/Domain/Repository/Episode/EpisodeRespository.php @@ -0,0 +1,38 @@ +db->getConnection()->query($query); + $results = $statement->fetch(\PDO::FETCH_ASSOC); + + if (!is_array($results) || !count($results)) { + throw new EntityNotFoundException("Unable to find Episode."); + } + + + } +}