Replace switch statement with array mapping
timw4mail/HummingBirdAnimeClient/develop There was a failure building this commit Details

This commit is contained in:
Timothy Warren 2018-10-17 14:20:07 -04:00
parent fccc794528
commit f243dd4583
1 changed files with 53 additions and 65 deletions

View File

@ -66,74 +66,62 @@ final class Kitsu {
*/ */
protected static function getServiceMetaData(string $hostname = NULL): array protected static function getServiceMetaData(string $hostname = NULL): array
{ {
switch($hostname) $serviceMap = [
{ 'www.amazon.com' => [
case 'www.amazon.com':
return [
'name' => 'Amazon Prime', 'name' => 'Amazon Prime',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/amazon.svg', 'image' => 'streaming-logos/amazon.svg',
]; ],
'www.crunchyroll.com' => [
case 'www.crunchyroll.com':
return [
'name' => 'Crunchyroll', 'name' => 'Crunchyroll',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/crunchyroll.svg', 'image' => 'streaming-logos/crunchyroll.svg',
]; ],
'www.daisuki.net' => [
case 'www.daisuki.net':
return [
'name' => 'Daisuki', 'name' => 'Daisuki',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/daisuki.svg' 'image' => 'streaming-logos/daisuki.svg'
]; ],
'wwww.funimation.com' => [
case 'www.funimation.com':
return [
'name' => 'Funimation', 'name' => 'Funimation',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/funimation.svg', 'image' => 'streaming-logos/funimation.svg',
]; ],
'www.hidive.com' => [
case 'www.hidive.com':
return [
'name' => 'Hidive', 'name' => 'Hidive',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/hidive.svg', 'image' => 'streaming-logos/hidive.svg',
]; ],
'www.hulu.com' => [
case 'www.hulu.com':
return [
'name' => 'Hulu', 'name' => 'Hulu',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/hulu.svg', 'image' => 'streaming-logos/hulu.svg',
]; ],
'tubitv.com' => [
case 'tubitv.com':
return [
'name' => 'TubiTV', 'name' => 'TubiTV',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/tubitv.svg', 'image' => 'streaming-logos/tubitv.svg',
]; ],
'www.viewster.com' => [
case 'www.viewster.com':
return [
'name' => 'Viewster', 'name' => 'Viewster',
'link' => TRUE, 'link' => TRUE,
'image' => 'streaming-logos/viewster.svg' 'image' => 'streaming-logos/viewster.svg'
],
]; ];
if (array_key_exists($hostname, $serviceMap))
{
return $serviceMap[$hostname];
}
// Default to Netflix, because the API links are broken, // Default to Netflix, because the API links are broken,
// and there's no other real identifier for Netflix // and there's no other real identifier for Netflix
default:
return [ return [
'name' => 'Netflix', 'name' => 'Netflix',
'link' => FALSE, 'link' => FALSE,
'image' => 'streaming-logos/netflix.svg', 'image' => 'streaming-logos/netflix.svg',
]; ];
} }
}
/** /**
* Reorganize streaming links * Reorganize streaming links