Misc bugfixes, especially for Anime without a MAL id.
All checks were successful
timw4mail/HummingBirdAnimeClient/develop This commit looks good

This commit is contained in:
Timothy Warren 2019-10-07 20:10:27 -04:00
parent 361ebcbbe4
commit 848f667626
3 changed files with 21 additions and 3 deletions

View File

@ -274,6 +274,11 @@ final class Model
'type' => mb_strtoupper($type), 'type' => mb_strtoupper($type),
]); ]);
if (empty($info) || empty($info['data']))
{
return NULL;
}
return (string)$info['data']['Media']['id']; return (string)$info['data']['Media']['id'];
} }
} }

View File

@ -187,7 +187,7 @@ class Anime extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->incrementListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->incrementListItem($data), 'kitsu');
if ($this->anilistEnabled && $data['mal_id'] !== null) if (( ! empty($data['mal_id'])) && $this->anilistEnabled)
{ {
$requester->addRequest($this->anilistModel->incrementListItem($data, 'ANIME'), 'anilist'); $requester->addRequest($this->anilistModel->incrementListItem($data, 'ANIME'), 'anilist');
} }
@ -214,7 +214,7 @@ class Anime extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu');
if ($this->anilistEnabled && $data['mal_id'] !== null) if (( ! empty($data['mal_id'])) && $this->anilistEnabled)
{ {
$requester->addRequest($this->anilistModel->updateListItem($data, 'ANIME'), 'anilist'); $requester->addRequest($this->anilistModel->updateListItem($data, 'ANIME'), 'anilist');
} }

View File

@ -17,8 +17,10 @@
namespace Aviat\AnimeClient\Types; namespace Aviat\AnimeClient\Types;
use ArrayAccess; use ArrayAccess;
use ArrayObject;
use Countable;
abstract class AbstractType implements ArrayAccess { abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Populate values for un-serializing data * Populate values for un-serializing data
* *
@ -164,6 +166,17 @@ abstract class AbstractType implements ArrayAccess {
} }
} }
/**
* Implementing Countable
*
* @return int
*/
public function count(): int
{
$keys = array_keys($this->toArray());
return count($keys);
}
/** /**
* Recursively cast properties to an array * Recursively cast properties to an array
* *