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."); + } + + + } +}