Minor api model refactoring

This commit is contained in:
Timothy Warren 2017-03-28 14:36:23 -04:00
parent 754a5e7b98
commit 4f528ca2c8
3 changed files with 17 additions and 11 deletions

View File

@ -21,6 +21,13 @@ namespace Aviat\AnimeClient\Model;
*/
class API extends AbstractModel {
/**
* Whether to use the MAL api
*
* @var boolean
*/
protected $useMALAPI;
/**
* Sort the list entries by their title
*

View File

@ -39,13 +39,6 @@ class Anime extends API {
*/
protected $malModel;
/**
* Whether to use the MAL api
*
* @var boolean
*/
protected $useMALAPI;
/**
* Anime constructor.
*
@ -53,10 +46,10 @@ class Anime extends API {
*/
public function __construct(ContainerInterface $container)
{
$config = $container->get('config');
$this->kitsuModel = $container->get('kitsu-model');
$this->malModel = $container->get('mal-model');
$config = $container->get('config');
$this->useMALAPI = $config->get(['use_mal_api']) === TRUE;
}

View File

@ -16,8 +16,11 @@
namespace Aviat\AnimeClient\Model;
use Aviat\AnimeClient\API\Enum\MangaReadingStatus\Title;
use Aviat\AnimeClient\API\Mapping\MangaReadingStatus;
use Aviat\AnimeClient\API\{
Enum\MangaReadingStatus\Title,
Mapping\MangaReadingStatus,
ParallelAPIRequest
};
use Aviat\Ion\Di\ContainerInterface;
/**
@ -46,6 +49,9 @@ class Manga extends API
{
$this->kitsuModel = $container->get('kitsu-model');
$this->malModel = $container->get('mal-model');
$config = $container->get('config');
$this->useMALAPI = $config->get(['use_mal_api']) === TRUE;
}
/**
@ -60,7 +66,7 @@ class Manga extends API
{
return $this->kitsuModel->getFullOrganizedMangaList();
}
$APIstatus = MangaReadingStatus::TITLE_TO_KITSU[$status];
$data = $this->kitsuModel->getMangaList($APIstatus);
return $this->mapByStatus($data)[$status];