From 2d44435c598f8c78d665704c7dd57b2d89d0c0f4 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Fri, 1 May 2020 19:38:45 -0400 Subject: [PATCH] Various code tweaks --- .../Transformer/AnimeListTransformer.php | 2 +- src/AnimeClient/API/Kitsu/KitsuTrait.php | 2 +- src/AnimeClient/Enum/APISource.php | 27 +++++++++++++++++++ src/Ion/Di/ContainerAware.php | 2 +- src/Ion/Enum.php | 7 ++--- 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 src/AnimeClient/Enum/APISource.php diff --git a/src/AnimeClient/API/Anilist/Transformer/AnimeListTransformer.php b/src/AnimeClient/API/Anilist/Transformer/AnimeListTransformer.php index 8187e60d..c09f63c1 100644 --- a/src/AnimeClient/API/Anilist/Transformer/AnimeListTransformer.php +++ b/src/AnimeClient/API/Anilist/Transformer/AnimeListTransformer.php @@ -29,7 +29,7 @@ class AnimeListTransformer extends AbstractTransformer { public function transform($item): AnimeListItem { - return new AnimeListItem([]); + return AnimeListItem::from([]); } /** diff --git a/src/AnimeClient/API/Kitsu/KitsuTrait.php b/src/AnimeClient/API/Kitsu/KitsuTrait.php index 7242246a..1041c3c2 100644 --- a/src/AnimeClient/API/Kitsu/KitsuTrait.php +++ b/src/AnimeClient/API/Kitsu/KitsuTrait.php @@ -176,7 +176,7 @@ trait KitsuTrait { $logger->warning('Non 200 response for api call', (array)$response); } - // throw new FailedResponseException('Failed to get the proper response from the API'); + throw new FailedResponseException('Failed to get the proper response from the API'); } try diff --git a/src/AnimeClient/Enum/APISource.php b/src/AnimeClient/Enum/APISource.php new file mode 100644 index 00000000..65549401 --- /dev/null +++ b/src/AnimeClient/Enum/APISource.php @@ -0,0 +1,27 @@ + + * @copyright 2015 - 2020 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 5 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Enum; + +use Aviat\Ion\Enum as BaseEnum; + +/** + * Types of lists + */ +final class APISource extends BaseEnum { + public const KITSU = 'kitsu'; + public const ANILIST = 'anilist'; +} \ No newline at end of file diff --git a/src/Ion/Di/ContainerAware.php b/src/Ion/Di/ContainerAware.php index 3b43a0cf..4da0f84d 100644 --- a/src/Ion/Di/ContainerAware.php +++ b/src/Ion/Di/ContainerAware.php @@ -26,7 +26,7 @@ trait ContainerAware { * * @var ContainerInterface */ - protected $container; + protected ContainerInterface $container; /** * Set the container for the current object diff --git a/src/Ion/Enum.php b/src/Ion/Enum.php index e51bfc6a..d0b3a610 100644 --- a/src/Ion/Enum.php +++ b/src/Ion/Enum.php @@ -17,6 +17,7 @@ namespace Aviat\Ion; use ReflectionClass; +use ReflectionException; /** * Class emulating an enumeration type @@ -27,7 +28,7 @@ abstract class Enum { * Return the list of constant values for the Enum * * @return array - * @throws \ReflectionException + * @throws ReflectionException */ public static function getConstList(): array { @@ -48,12 +49,12 @@ abstract class Enum { * * @param mixed $key * @return boolean - * @throws \ReflectionException + * @throws ReflectionException */ public static function isValid($key): bool { $values = array_values(static::getConstList()); - return \in_array($key, $values, TRUE); + return in_array($key, $values, TRUE); } } // End of Enum.php \ No newline at end of file