From 9045eb6b8f1a762cd0920b772efb6b2661a7abd6 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Mon, 4 May 2020 17:15:50 -0400 Subject: [PATCH] Comment cleanup of sync command --- src/AnimeClient/Command/SyncLists.php | 43 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/AnimeClient/Command/SyncLists.php b/src/AnimeClient/Command/SyncLists.php index cf1732fd..5daaa9a3 100644 --- a/src/AnimeClient/Command/SyncLists.php +++ b/src/AnimeClient/Command/SyncLists.php @@ -74,27 +74,13 @@ final class SyncLists extends BaseCommand { foreach ([ListType::ANIME, ListType::MANGA] as $type) { + // Main Sync flow $this->fetchCount($type); $rawData = $this->fetch($type); $normalized = $this->transform($type, $rawData); $compared = $this->compare($type, $normalized); - - /* $toUpdateCounts = [ - 'addToAnilist' => count($compared['addToAnilist']), - 'updateAnilist' => count($compared['updateAnilist']), - 'addToKitsu' => count($compared['addToKitsu']), - 'updateKitsu' => count($compared['updateKitsu']), - ]; - - dump($toUpdateCounts); */ - $this->update($type, $compared); } - - /* $this->sync(ListType::ANIME); - $this->sync(ListType::MANGA); - - $this->echoBox('Finished syncing lists'); */ } // ------------------------------------------------------------------------ @@ -158,6 +144,12 @@ final class SyncLists extends BaseCommand { $this->echoBox($displayLines); } + /** + * Get the list data + * + * @param string $type + * @return array + */ protected function fetch(string $type): array { $this->echo('Fetching List Data'); @@ -177,6 +169,13 @@ final class SyncLists extends BaseCommand { ]; } + /** + * Normalize the list data for comparison + * + * @param string $type + * @param array $data + * @return array + */ protected function transform(string $type, array $data): array { $this->echo('Normalizing List Data'); @@ -196,6 +195,13 @@ final class SyncLists extends BaseCommand { ]; } + /** + * Compare the lists data + * + * @param string $type + * @param array $data + * @return array|array[] + */ protected function compare(string $type, array $data): array { $this->echo('Comparing List Items'); @@ -203,6 +209,13 @@ final class SyncLists extends BaseCommand { return $this->compareLists($type, $data['anilist'], $data['kitsu']); } + /** + * Updated outdated list items + * + * @param string $type + * @param array $data + * @throws Throwable + */ protected function update(string $type, array $data) { if ( ! empty($data['addToAnilist']))