Remove some naming redundancies
All checks were successful
timw4mail/HummingBirdAnimeClient/pipeline/head This commit looks good
All checks were successful
timw4mail/HummingBirdAnimeClient/pipeline/head This commit looks good
This commit is contained in:
parent
ca8a0edad0
commit
65a8da755a
@ -19,12 +19,7 @@ namespace Aviat\AnimeClient;
|
|||||||
use Aura\Html\HelperLocatorFactory;
|
use Aura\Html\HelperLocatorFactory;
|
||||||
use Aura\Router\RouterContainer;
|
use Aura\Router\RouterContainer;
|
||||||
use Aura\Session\SessionFactory;
|
use Aura\Session\SessionFactory;
|
||||||
use Aviat\AnimeClient\API\{
|
use Aviat\AnimeClient\API\{Anilist, Kitsu};
|
||||||
Anilist,
|
|
||||||
Anilist\AnilistRequestBuilder,
|
|
||||||
Kitsu,
|
|
||||||
Kitsu\KitsuRequestBuilder
|
|
||||||
};
|
|
||||||
use Aviat\AnimeClient\Model;
|
use Aviat\AnimeClient\Model;
|
||||||
use Aviat\Banker\Teller;
|
use Aviat\Banker\Teller;
|
||||||
use Aviat\Ion\Config;
|
use Aviat\Ion\Config;
|
||||||
@ -114,7 +109,7 @@ return static function (array $configArray = []): Container {
|
|||||||
|
|
||||||
// Models
|
// Models
|
||||||
$container->set('kitsu-model', static function(ContainerInterface $container): Kitsu\Model {
|
$container->set('kitsu-model', static function(ContainerInterface $container): Kitsu\Model {
|
||||||
$requestBuilder = new KitsuRequestBuilder($container);
|
$requestBuilder = new Kitsu\RequestBuilder($container);
|
||||||
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
||||||
|
|
||||||
$listItem = new Kitsu\ListItem();
|
$listItem = new Kitsu\ListItem();
|
||||||
@ -130,7 +125,7 @@ return static function (array $configArray = []): Container {
|
|||||||
return $model;
|
return $model;
|
||||||
});
|
});
|
||||||
$container->set('anilist-model', static function(ContainerInterface $container): Anilist\Model {
|
$container->set('anilist-model', static function(ContainerInterface $container): Anilist\Model {
|
||||||
$requestBuilder = new AnilistRequestBuilder($container);
|
$requestBuilder = new Anilist\RequestBuilder($container);
|
||||||
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
||||||
|
|
||||||
$listItem = new Anilist\ListItem();
|
$listItem = new Anilist\ListItem();
|
||||||
|
@ -34,7 +34,7 @@ use function Aviat\AnimeClient\getLocalImg;
|
|||||||
</tr>
|
</tr>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if (isset($data['total_length'], $data['episode_count'])): ?>
|
<?php if (isset($data['total_length'], $data['episode_count']) && ! empty($data['total_length'])): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Total Length</td>
|
<td>Total Length</td>
|
||||||
<td><?= Kitsu::friendlyTime($data['total_length']) ?></td>
|
<td><?= Kitsu::friendlyTime($data['total_length']) ?></td>
|
||||||
|
@ -32,6 +32,14 @@ abstract class AbstractListItem {
|
|||||||
*/
|
*/
|
||||||
abstract public function create(array $data): Request;
|
abstract public function create(array $data): Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a full list item for syncing
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Request
|
||||||
|
*/
|
||||||
|
abstract public function createFull(array $data): Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list item
|
* Retrieve a list item
|
||||||
*
|
*
|
||||||
|
@ -27,7 +27,7 @@ use Aviat\AnimeClient\Types\FormItemData;
|
|||||||
* CRUD operations for MAL list items
|
* CRUD operations for MAL list items
|
||||||
*/
|
*/
|
||||||
final class ListItem extends AbstractListItem {
|
final class ListItem extends AbstractListItem {
|
||||||
use AnilistTrait;
|
use RequestBuilderTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a minimal list item
|
* Create a minimal list item
|
||||||
|
@ -35,7 +35,7 @@ use Throwable;
|
|||||||
*/
|
*/
|
||||||
final class Model
|
final class Model
|
||||||
{
|
{
|
||||||
use AnilistTrait;
|
use RequestBuilderTrait;
|
||||||
/**
|
/**
|
||||||
* @var ListItem
|
* @var ListItem
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +30,7 @@ use const Aviat\AnimeClient\USER_AGENT;
|
|||||||
|
|
||||||
use Aviat\AnimeClient\API\APIRequestBuilder;
|
use Aviat\AnimeClient\API\APIRequestBuilder;
|
||||||
|
|
||||||
final class AnilistRequestBuilder extends APIRequestBuilder {
|
final class RequestBuilder extends APIRequestBuilder {
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
|
|
||||||
/**
|
/**
|
@ -18,19 +18,19 @@ namespace Aviat\AnimeClient\API\Anilist;
|
|||||||
|
|
||||||
use Aviat\Ion\Di\ContainerAware;
|
use Aviat\Ion\Di\ContainerAware;
|
||||||
|
|
||||||
trait AnilistTrait {
|
trait RequestBuilderTrait {
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The request builder for the Anilist API
|
* The request builder for the Anilist API
|
||||||
* @var AnilistRequestBuilder
|
* @var RequestBuilder
|
||||||
*/
|
*/
|
||||||
protected AnilistRequestBuilder $requestBuilder;
|
protected RequestBuilder $requestBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the request builder object
|
* Set the request builder object
|
||||||
*
|
*
|
||||||
* @param AnilistRequestBuilder $requestBuilder
|
* @param RequestBuilder $requestBuilder
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setRequestBuilder($requestBuilder): self
|
public function setRequestBuilder($requestBuilder): self
|
@ -33,7 +33,7 @@ use Aviat\Ion\Json;
|
|||||||
/**
|
/**
|
||||||
* Anime-related list methods
|
* Anime-related list methods
|
||||||
*/
|
*/
|
||||||
trait KitsuAnimeTrait {
|
trait AnimeTrait {
|
||||||
/**
|
/**
|
||||||
* Class to map anime list items
|
* Class to map anime list items
|
||||||
* to a common format used by
|
* to a common format used by
|
@ -35,7 +35,7 @@ use Throwable;
|
|||||||
*/
|
*/
|
||||||
final class ListItem extends AbstractListItem {
|
final class ListItem extends AbstractListItem {
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
use KitsuTrait;
|
use RequestBuilderTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@ -33,7 +33,7 @@ use Aviat\Ion\Json;
|
|||||||
/**
|
/**
|
||||||
* Manga-related list methods
|
* Manga-related list methods
|
||||||
*/
|
*/
|
||||||
trait KitsuMangaTrait {
|
trait MangaTrait {
|
||||||
/**
|
/**
|
||||||
* @var MangaTransformer
|
* @var MangaTransformer
|
||||||
*/
|
*/
|
@ -43,10 +43,10 @@ use Throwable;
|
|||||||
final class Model {
|
final class Model {
|
||||||
use CacheTrait;
|
use CacheTrait;
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
use KitsuTrait;
|
use RequestBuilderTrait;
|
||||||
use KitsuAnimeTrait;
|
use AnimeTrait;
|
||||||
use KitsuMangaTrait;
|
use MangaTrait;
|
||||||
use KitsuMutationTrait;
|
use MutationTrait;
|
||||||
|
|
||||||
protected const LIST_PAGE_SIZE = 100;
|
protected const LIST_PAGE_SIZE = 100;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ use Aviat\Banker\Exception\InvalidArgumentException;
|
|||||||
/**
|
/**
|
||||||
* Kitsu API calls that mutate data, C/U/D parts of CRUD
|
* Kitsu API calls that mutate data, C/U/D parts of CRUD
|
||||||
*/
|
*/
|
||||||
trait KitsuMutationTrait {
|
trait MutationTrait {
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// ! Generic API calls
|
// ! Generic API calls
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
@ -34,7 +34,7 @@ use Aviat\Ion\Event;
|
|||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use Aviat\Ion\JsonException;
|
use Aviat\Ion\JsonException;
|
||||||
|
|
||||||
final class KitsuRequestBuilder extends APIRequestBuilder {
|
final class RequestBuilder extends APIRequestBuilder {
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -397,20 +397,11 @@ final class KitsuRequestBuilder extends APIRequestBuilder {
|
|||||||
{
|
{
|
||||||
$logger->warning('Non 2xx response for api call', (array)$response);
|
$logger->warning('Non 2xx response for api call', (array)$response);
|
||||||
}
|
}
|
||||||
|
dump($rawBody);
|
||||||
throw new FailedResponseException('Failed to get the proper response from the API');
|
die();
|
||||||
|
// throw new FailedResponseException('Failed to get the proper response from the API');
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
return Json::decode($rawBody);
|
||||||
{
|
|
||||||
return Json::decode(wait($response->getBody()->buffer()));
|
|
||||||
}
|
|
||||||
catch (JsonException $e)
|
|
||||||
{
|
|
||||||
print_r($e);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -16,20 +16,20 @@
|
|||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Kitsu;
|
namespace Aviat\AnimeClient\API\Kitsu;
|
||||||
|
|
||||||
trait KitsuTrait {
|
trait RequestBuilderTrait {
|
||||||
/**
|
/**
|
||||||
* The request builder for the Kitsu API
|
* The request builder for the Kitsu API
|
||||||
* @var KitsuRequestBuilder
|
* @var RequestBuilder
|
||||||
*/
|
*/
|
||||||
protected KitsuRequestBuilder $requestBuilder;
|
protected RequestBuilder $requestBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the request builder object
|
* Set the request builder object
|
||||||
*
|
*
|
||||||
* @param KitsuRequestBuilder $requestBuilder
|
* @param RequestBuilder $requestBuilder
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setRequestBuilder(KitsuRequestBuilder $requestBuilder): self
|
public function setRequestBuilder(RequestBuilder $requestBuilder): self
|
||||||
{
|
{
|
||||||
$this->requestBuilder = $requestBuilder;
|
$this->requestBuilder = $requestBuilder;
|
||||||
return $this;
|
return $this;
|
@ -23,7 +23,6 @@ use Aura\Router\RouterContainer;
|
|||||||
use Aura\Session\SessionFactory;
|
use Aura\Session\SessionFactory;
|
||||||
use Aviat\AnimeClient\{Model, UrlGenerator, Util};
|
use Aviat\AnimeClient\{Model, UrlGenerator, Util};
|
||||||
use Aviat\AnimeClient\API\{Anilist, CacheTrait, Kitsu};
|
use Aviat\AnimeClient\API\{Anilist, CacheTrait, Kitsu};
|
||||||
use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
|
|
||||||
use Aviat\Banker\Teller;
|
use Aviat\Banker\Teller;
|
||||||
use Aviat\Ion\Config;
|
use Aviat\Ion\Config;
|
||||||
use Aviat\Ion\Di\{Container, ContainerInterface, ContainerAware};
|
use Aviat\Ion\Di\{Container, ContainerInterface, ContainerAware};
|
||||||
@ -187,7 +186,7 @@ abstract class BaseCommand extends Command {
|
|||||||
|
|
||||||
// Models
|
// Models
|
||||||
$container->set('kitsu-model', static function($container): Kitsu\Model {
|
$container->set('kitsu-model', static function($container): Kitsu\Model {
|
||||||
$requestBuilder = new KitsuRequestBuilder($container);
|
$requestBuilder = new Kitsu\RequestBuilder($container);
|
||||||
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
||||||
|
|
||||||
$listItem = new Kitsu\ListItem();
|
$listItem = new Kitsu\ListItem();
|
||||||
@ -203,7 +202,7 @@ abstract class BaseCommand extends Command {
|
|||||||
return $model;
|
return $model;
|
||||||
});
|
});
|
||||||
$container->set('anilist-model', static function ($container): Anilist\Model {
|
$container->set('anilist-model', static function ($container): Anilist\Model {
|
||||||
$requestBuilder = new Anilist\AnilistRequestBuilder($container);
|
$requestBuilder = new Anilist\RequestBuilder($container);
|
||||||
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
||||||
|
|
||||||
$listItem = new Anilist\ListItem();
|
$listItem = new Anilist\ListItem();
|
||||||
|
Loading…
Reference in New Issue
Block a user