From 5d87bd044c3d335f3ad6bfb42f7e0d26e07d074a Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 19 Oct 2018 10:40:11 -0400 Subject: [PATCH] Refactor some silly switches --- src/API/Kitsu.php | 18 +++++++++--------- src/API/Kitsu/Model.php | 29 ++++++++++++++--------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/API/Kitsu.php b/src/API/Kitsu.php index 0f761f8f..6814d2fc 100644 --- a/src/API/Kitsu.php +++ b/src/API/Kitsu.php @@ -45,17 +45,17 @@ final class Kitsu { $isDoneAiring = $now > $endAirDate; $isCurrentlyAiring = ($now > $startAirDate) && ! $isDoneAiring; - switch (TRUE) + if ($isCurrentlyAiring) { - case $isCurrentlyAiring: - return AnimeAiringStatus::AIRING; - - case $isDoneAiring: - return AnimeAiringStatus::FINISHED_AIRING; - - default: - return AnimeAiringStatus::NOT_YET_AIRED; + return AnimeAiringStatus::AIRING; } + + if ($isDoneAiring) + { + return AnimeAiringStatus::FINISHED_AIRING; + } + + return AnimeAiringStatus::NOT_YET_AIRED; } /** diff --git a/src/API/Kitsu/Model.php b/src/API/Kitsu/Model.php index e06c8ef8..eb3fb05b 100644 --- a/src/API/Kitsu/Model.php +++ b/src/API/Kitsu/Model.php @@ -839,23 +839,22 @@ final class Model { $baseData = $this->listItem->get($listId); $included = JsonAPI::organizeIncludes($baseData['included']); - - switch (TRUE) + if (array_key_exists('anime', $included)) { - case array_key_exists('anime', $included): // in_array('anime', array_keys($included)): - $included = JsonAPI::inlineIncludedRelationships($included, 'anime'); - $baseData['data']['included'] = $included; - return $this->animeListTransformer->transform($baseData['data']); - - case array_key_exists('manga', $included): // in_array('manga', array_keys($included)): - $included = JsonAPI::inlineIncludedRelationships($included, 'manga'); - $baseData['data']['included'] = $included; - $baseData['data']['manga'] = $baseData['included'][0]; - return $this->mangaListTransformer->transform($baseData['data']); - - default: - return $baseData['data']; + $included = JsonAPI::inlineIncludedRelationships($included, 'anime'); + $baseData['data']['included'] = $included; + return $this->animeListTransformer->transform($baseData['data']); } + + if (array_key_exists('manga', $included)) + { + $included = JsonAPI::inlineIncludedRelationships($included, 'manga'); + $baseData['data']['included'] = $included; + $baseData['data']['manga'] = $baseData['included'][0]; + return $this->mangaListTransformer->transform($baseData['data']); + } + + return $baseData['data']; } /**