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\Router\RouterContainer;
|
||||
use Aura\Session\SessionFactory;
|
||||
use Aviat\AnimeClient\API\{
|
||||
Anilist,
|
||||
Anilist\AnilistRequestBuilder,
|
||||
Kitsu,
|
||||
Kitsu\KitsuRequestBuilder
|
||||
};
|
||||
use Aviat\AnimeClient\API\{Anilist, Kitsu};
|
||||
use Aviat\AnimeClient\Model;
|
||||
use Aviat\Banker\Teller;
|
||||
use Aviat\Ion\Config;
|
||||
@ -114,7 +109,7 @@ return static function (array $configArray = []): Container {
|
||||
|
||||
// Models
|
||||
$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'));
|
||||
|
||||
$listItem = new Kitsu\ListItem();
|
||||
@ -130,7 +125,7 @@ return static function (array $configArray = []): Container {
|
||||
return $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'));
|
||||
|
||||
$listItem = new Anilist\ListItem();
|
||||
|
@ -34,7 +34,7 @@ use function Aviat\AnimeClient\getLocalImg;
|
||||
</tr>
|
||||
<?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>
|
||||
<td>Total Length</td>
|
||||
<td><?= Kitsu::friendlyTime($data['total_length']) ?></td>
|
||||
|
@ -32,6 +32,14 @@ abstract class AbstractListItem {
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
@ -27,7 +27,7 @@ use Aviat\AnimeClient\Types\FormItemData;
|
||||
* CRUD operations for MAL list items
|
||||
*/
|
||||
final class ListItem extends AbstractListItem {
|
||||
use AnilistTrait;
|
||||
use RequestBuilderTrait;
|
||||
|
||||
/**
|
||||
* Create a minimal list item
|
||||
|
@ -35,7 +35,7 @@ use Throwable;
|
||||
*/
|
||||
final class Model
|
||||
{
|
||||
use AnilistTrait;
|
||||
use RequestBuilderTrait;
|
||||
/**
|
||||
* @var ListItem
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ use const Aviat\AnimeClient\USER_AGENT;
|
||||
|
||||
use Aviat\AnimeClient\API\APIRequestBuilder;
|
||||
|
||||
final class AnilistRequestBuilder extends APIRequestBuilder {
|
||||
final class RequestBuilder extends APIRequestBuilder {
|
||||
use ContainerAware;
|
||||
|
||||
/**
|
@ -18,19 +18,19 @@ namespace Aviat\AnimeClient\API\Anilist;
|
||||
|
||||
use Aviat\Ion\Di\ContainerAware;
|
||||
|
||||
trait AnilistTrait {
|
||||
trait RequestBuilderTrait {
|
||||
use ContainerAware;
|
||||
|
||||
/**
|
||||
* The request builder for the Anilist API
|
||||
* @var AnilistRequestBuilder
|
||||
* @var RequestBuilder
|
||||
*/
|
||||
protected AnilistRequestBuilder $requestBuilder;
|
||||
protected RequestBuilder $requestBuilder;
|
||||
|
||||
/**
|
||||
* Set the request builder object
|
||||
*
|
||||
* @param AnilistRequestBuilder $requestBuilder
|
||||
* @param RequestBuilder $requestBuilder
|
||||
* @return self
|
||||
*/
|
||||
public function setRequestBuilder($requestBuilder): self
|
@ -33,7 +33,7 @@ use Aviat\Ion\Json;
|
||||
/**
|
||||
* Anime-related list methods
|
||||
*/
|
||||
trait KitsuAnimeTrait {
|
||||
trait AnimeTrait {
|
||||
/**
|
||||
* Class to map anime list items
|
||||
* to a common format used by
|
@ -35,7 +35,7 @@ use Throwable;
|
||||
*/
|
||||
final class ListItem extends AbstractListItem {
|
||||
use ContainerAware;
|
||||
use KitsuTrait;
|
||||
use RequestBuilderTrait;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
|
@ -33,7 +33,7 @@ use Aviat\Ion\Json;
|
||||
/**
|
||||
* Manga-related list methods
|
||||
*/
|
||||
trait KitsuMangaTrait {
|
||||
trait MangaTrait {
|
||||
/**
|
||||
* @var MangaTransformer
|
||||
*/
|
@ -43,10 +43,10 @@ use Throwable;
|
||||
final class Model {
|
||||
use CacheTrait;
|
||||
use ContainerAware;
|
||||
use KitsuTrait;
|
||||
use KitsuAnimeTrait;
|
||||
use KitsuMangaTrait;
|
||||
use KitsuMutationTrait;
|
||||
use RequestBuilderTrait;
|
||||
use AnimeTrait;
|
||||
use MangaTrait;
|
||||
use MutationTrait;
|
||||
|
||||
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
|
||||
*/
|
||||
trait KitsuMutationTrait {
|
||||
trait MutationTrait {
|
||||
// -------------------------------------------------------------------------
|
||||
// ! Generic API calls
|
||||
// -------------------------------------------------------------------------
|
@ -34,7 +34,7 @@ use Aviat\Ion\Event;
|
||||
use Aviat\Ion\Json;
|
||||
use Aviat\Ion\JsonException;
|
||||
|
||||
final class KitsuRequestBuilder extends APIRequestBuilder {
|
||||
final class RequestBuilder extends APIRequestBuilder {
|
||||
use ContainerAware;
|
||||
|
||||
/**
|
||||
@ -397,20 +397,11 @@ final class KitsuRequestBuilder extends APIRequestBuilder {
|
||||
{
|
||||
$logger->warning('Non 2xx response for api call', (array)$response);
|
||||
}
|
||||
|
||||
throw new FailedResponseException('Failed to get the proper response from the API');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Json::decode(wait($response->getBody()->buffer()));
|
||||
}
|
||||
catch (JsonException $e)
|
||||
{
|
||||
print_r($e);
|
||||
dump($rawBody);
|
||||
die();
|
||||
}
|
||||
// throw new FailedResponseException('Failed to get the proper response from the API');
|
||||
}
|
||||
|
||||
|
||||
return Json::decode($rawBody);
|
||||
}
|
||||
}
|
@ -16,20 +16,20 @@
|
||||
|
||||
namespace Aviat\AnimeClient\API\Kitsu;
|
||||
|
||||
trait KitsuTrait {
|
||||
trait RequestBuilderTrait {
|
||||
/**
|
||||
* The request builder for the Kitsu API
|
||||
* @var KitsuRequestBuilder
|
||||
* @var RequestBuilder
|
||||
*/
|
||||
protected KitsuRequestBuilder $requestBuilder;
|
||||
protected RequestBuilder $requestBuilder;
|
||||
|
||||
/**
|
||||
* Set the request builder object
|
||||
*
|
||||
* @param KitsuRequestBuilder $requestBuilder
|
||||
* @param RequestBuilder $requestBuilder
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequestBuilder(KitsuRequestBuilder $requestBuilder): self
|
||||
public function setRequestBuilder(RequestBuilder $requestBuilder): self
|
||||
{
|
||||
$this->requestBuilder = $requestBuilder;
|
||||
return $this;
|
@ -23,7 +23,6 @@ use Aura\Router\RouterContainer;
|
||||
use Aura\Session\SessionFactory;
|
||||
use Aviat\AnimeClient\{Model, UrlGenerator, Util};
|
||||
use Aviat\AnimeClient\API\{Anilist, CacheTrait, Kitsu};
|
||||
use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
|
||||
use Aviat\Banker\Teller;
|
||||
use Aviat\Ion\Config;
|
||||
use Aviat\Ion\Di\{Container, ContainerInterface, ContainerAware};
|
||||
@ -187,7 +186,7 @@ abstract class BaseCommand extends Command {
|
||||
|
||||
// Models
|
||||
$container->set('kitsu-model', static function($container): Kitsu\Model {
|
||||
$requestBuilder = new KitsuRequestBuilder($container);
|
||||
$requestBuilder = new Kitsu\RequestBuilder($container);
|
||||
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
||||
|
||||
$listItem = new Kitsu\ListItem();
|
||||
@ -203,7 +202,7 @@ abstract class BaseCommand extends Command {
|
||||
return $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'));
|
||||
|
||||
$listItem = new Anilist\ListItem();
|
||||
|
Loading…
Reference in New Issue
Block a user