Refactor some silly switches

This commit is contained in:
Timothy Warren 2018-10-19 10:40:11 -04:00
parent e2b4fae83b
commit 5d87bd044c
2 changed files with 23 additions and 24 deletions

View File

@ -45,17 +45,17 @@ final class Kitsu {
$isDoneAiring = $now > $endAirDate; $isDoneAiring = $now > $endAirDate;
$isCurrentlyAiring = ($now > $startAirDate) && ! $isDoneAiring; $isCurrentlyAiring = ($now > $startAirDate) && ! $isDoneAiring;
switch (TRUE) if ($isCurrentlyAiring)
{ {
case $isCurrentlyAiring:
return AnimeAiringStatus::AIRING; return AnimeAiringStatus::AIRING;
case $isDoneAiring:
return AnimeAiringStatus::FINISHED_AIRING;
default:
return AnimeAiringStatus::NOT_YET_AIRED;
} }
if ($isDoneAiring)
{
return AnimeAiringStatus::FINISHED_AIRING;
}
return AnimeAiringStatus::NOT_YET_AIRED;
} }
/** /**

View File

@ -839,23 +839,22 @@ final class Model {
$baseData = $this->listItem->get($listId); $baseData = $this->listItem->get($listId);
$included = JsonAPI::organizeIncludes($baseData['included']); $included = JsonAPI::organizeIncludes($baseData['included']);
if (array_key_exists('anime', $included))
switch (TRUE)
{ {
case array_key_exists('anime', $included): // in_array('anime', array_keys($included)):
$included = JsonAPI::inlineIncludedRelationships($included, 'anime'); $included = JsonAPI::inlineIncludedRelationships($included, 'anime');
$baseData['data']['included'] = $included; $baseData['data']['included'] = $included;
return $this->animeListTransformer->transform($baseData['data']); return $this->animeListTransformer->transform($baseData['data']);
}
case array_key_exists('manga', $included): // in_array('manga', array_keys($included)): if (array_key_exists('manga', $included))
{
$included = JsonAPI::inlineIncludedRelationships($included, 'manga'); $included = JsonAPI::inlineIncludedRelationships($included, 'manga');
$baseData['data']['included'] = $included; $baseData['data']['included'] = $included;
$baseData['data']['manga'] = $baseData['included'][0]; $baseData['data']['manga'] = $baseData['included'][0];
return $this->mangaListTransformer->transform($baseData['data']); return $this->mangaListTransformer->transform($baseData['data']);
default:
return $baseData['data'];
} }
return $baseData['data'];
} }
/** /**