From 204313abbfd1bb6c85287ce10ee8e33344ef1ec1 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Wed, 11 Apr 2018 09:26:14 -0400 Subject: [PATCH] Use more efficient method of combining large sets of data from Kitsu --- src/API/Kitsu/Model.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/API/Kitsu/Model.php b/src/API/Kitsu/Model.php index 3df6f9c4..6d2077f1 100644 --- a/src/API/Kitsu/Model.php +++ b/src/API/Kitsu/Model.php @@ -26,7 +26,6 @@ use Aviat\AnimeClient\API\{ ParallelAPIRequest }; use Aviat\AnimeClient\API\Enum\{ - AnimeWatchingStatus\Title, AnimeWatchingStatus\Kitsu as KitsuWatchingStatus, MangaReadingStatus\Kitsu as KitsuReadingStatus }; @@ -47,7 +46,7 @@ class Model { use ContainerAware; use KitsuTrait; - const LIST_PAGE_SIZE = 100; + protected const LIST_PAGE_SIZE = 100; /** * Class to map anime list items @@ -417,7 +416,7 @@ class Model { * @param array $options * @return array */ - public function getFullAnimeList(array $options = [ + public function getFullRawAnimeList(array $options = [ 'include' => 'anime.mappings' ]): array { @@ -441,10 +440,10 @@ class Model { foreach($responses as $response) { $data = Json::decode($response); - $output = array_merge_recursive($output, $data); + $output[] = $data; } - return $output; + return array_merge_recursive(...$output); } /** @@ -547,7 +546,7 @@ class Model { 'sort' => '-updated_at' ]; - return $this->getFullAnimeList($options); + return $this->getFullRawAnimeList($options); } // ------------------------------------------------------------------------- @@ -680,7 +679,7 @@ class Model { * @param array $options * @return array */ - public function getFullMangaList(array $options = [ + public function getFullRawMangaList(array $options = [ 'include' => 'manga.mappings' ]): array { @@ -704,10 +703,10 @@ class Model { foreach($responses as $response) { $data = Json::decode($response); - $output = array_merge_recursive($output, $data); + $output[] = $data; } - return $output; + return array_merge_recursive(...$output); } /**