Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
20 changed files with 364 additions and 125 deletions
Showing only changes of commit efede08401 - Show all commits

3
.gitignore vendored
View File

@ -145,4 +145,5 @@ public/images/avatars/**
public/images/manga/** public/images/manga/**
public/images/characters/** public/images/characters/**
public/images/people/** public/images/people/**
public/mal_mappings.json public/mal_mappings.json
.phpunit.result.cache

View File

@ -44,10 +44,13 @@ return static function ($configArray = []) {
$appLogger = new Logger('animeclient'); $appLogger = new Logger('animeclient');
$appLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', Logger::NOTICE)); $appLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', Logger::NOTICE));
$anilistRequestLogger = new Logger('anilist-request'); $anilistRequestLogger = new Logger('anilist-request');
$anilistRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/anilist_request.log', Logger::NOTICE)); $anilistRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/anilist_request.log', Logger::NOTICE));
$kitsuRequestLogger = new Logger('kitsu-request'); $kitsuRequestLogger = new Logger('kitsu-request');
$kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE)); $kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE));
$container->setLogger($appLogger); $container->setLogger($appLogger);
$container->setLogger($anilistRequestLogger, 'anilist-request'); $container->setLogger($anilistRequestLogger, 'anilist-request');
$container->setLogger($kitsuRequestLogger, 'kitsu-request'); $container->setLogger($kitsuRequestLogger, 'kitsu-request');
@ -62,7 +65,7 @@ return static function ($configArray = []) {
}); });
// Create Cache Object // Create Cache Object
$container->set('cache', static function($container) { $container->set('cache', static function($container): Pool {
$logger = $container->getLogger(); $logger = $container->getLogger();
$config = $container->get('config')->get('cache'); $config = $container->get('config')->get('cache');
return new Pool($config, $logger); return new Pool($config, $logger);
@ -117,12 +120,12 @@ return static function ($configArray = []) {
}); });
// Miscellaneous helper methods // Miscellaneous helper methods
$container->set('util', static function($container) { $container->set('util', static function($container): Util {
return new Util($container); return new Util($container);
}); });
// Models // Models
$container->set('kitsu-model', static function($container) { $container->set('kitsu-model', static function($container): Kitsu\Model {
$requestBuilder = new KitsuRequestBuilder(); $requestBuilder = new KitsuRequestBuilder();
$requestBuilder->setLogger($container->getLogger('kitsu-request')); $requestBuilder->setLogger($container->getLogger('kitsu-request'));
@ -138,7 +141,7 @@ return static function ($configArray = []) {
$model->setCache($cache); $model->setCache($cache);
return $model; return $model;
}); });
$container->set('anilist-model', static function($container) { $container->set('anilist-model', static function($container): Anilist\Model {
$requestBuilder = new Anilist\AnilistRequestBuilder(); $requestBuilder = new Anilist\AnilistRequestBuilder();
$requestBuilder->setLogger($container->getLogger('anilist-request')); $requestBuilder->setLogger($container->getLogger('anilist-request'));
@ -153,9 +156,6 @@ return static function ($configArray = []) {
return $model; return $model;
}); });
$container->set('api-model', static function($container) {
return new Model\API($container);
});
$container->set('anime-model', static function($container) { $container->set('anime-model', static function($container) {
return new Model\Anime($container); return new Model\Anime($container);
}); });

View File

@ -15,41 +15,5 @@
<issueHandlers> <issueHandlers>
<LessSpecificReturnType errorLevel="info" /> <LessSpecificReturnType errorLevel="info" />
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />
<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />
<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />
<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />
<RedundantCondition errorLevel="info" />
<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />
<UnresolvableInclude errorLevel="info" />
<RawObjectIteration errorLevel="info" />
<InvalidStringClass errorLevel="info" />
</issueHandlers> </issueHandlers>
</psalm> </psalm>

View File

@ -100,7 +100,7 @@ final class AnimeListTransformer extends AbstractTransformer {
'title' => $title, 'title' => $title,
'titles' => $titles, 'titles' => $titles,
'slug' => $anime['slug'], 'slug' => $anime['slug'],
'show_type' => $this->string($anime['subtype'])->upperCaseFirst()->__toString(), 'show_type' => (string)$this->string($anime['subtype'])->upperCaseFirst(),
'cover_image' => $anime['posterImage']['small'], 'cover_image' => $anime['posterImage']['small'],
'genres' => $genres, 'genres' => $genres,
'streaming_links' => $streamingLinks, 'streaming_links' => $streamingLinks,

View File

@ -89,14 +89,14 @@ final class AnimeTransformer extends AbstractTransformer {
if ( ! empty($characters['main'])) if ( ! empty($characters['main']))
{ {
uasort($characters['main'], function ($a, $b) { uasort($characters['main'], static function ($a, $b) {
return $a['name'] <=> $b['name']; return $a['name'] <=> $b['name'];
}); });
} }
if ( ! empty($characters['supporting'])) if ( ! empty($characters['supporting']))
{ {
uasort($characters['supporting'], function ($a, $b) { uasort($characters['supporting'], static function ($a, $b) {
return $a['name'] <=> $b['name']; return $a['name'] <=> $b['name'];
}); });
} }
@ -114,7 +114,7 @@ final class AnimeTransformer extends AbstractTransformer {
'genres' => $item['genres'], 'genres' => $item['genres'],
'id' => $item['id'], 'id' => $item['id'],
'included' => $item['included'], 'included' => $item['included'],
'show_type' => $this->string($item['showType'])->upperCaseFirst()->__toString(), 'show_type' => (string)$this->string($item['showType'])->upperCaseFirst(),
'slug' => $item['slug'], 'slug' => $item['slug'],
'staff' => $staff, 'staff' => $staff,
'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']), 'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']),

View File

@ -46,7 +46,7 @@ class BaseCommand extends Command {
* @param string $message * @param string $message
* @return void * @return void
*/ */
protected function echoBox($message) protected function echoBox($message): void
{ {
try try
{ {
@ -82,7 +82,7 @@ class BaseCommand extends Command {
$configArray = array_replace_recursive($baseConfig, $config, $overrideConfig); $configArray = array_replace_recursive($baseConfig, $config, $overrideConfig);
$di = static function ($configArray) use ($APP_DIR) { $di = static function ($configArray) use ($APP_DIR): Container {
$container = new Container(); $container = new Container();
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -91,16 +91,19 @@ class BaseCommand extends Command {
$app_logger = new Logger('animeclient'); $app_logger = new Logger('animeclient');
$app_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', Logger::NOTICE)); $app_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', Logger::NOTICE));
$kitsu_request_logger = new Logger('kitsu-request'); $kitsu_request_logger = new Logger('kitsu-request');
$kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE)); $kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE));
$anilistRequestLogger = new Logger('anilist-request'); $anilistRequestLogger = new Logger('anilist-request');
$anilistRequestLogger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/anilist_request-cli.log', Logger::NOTICE)); $anilistRequestLogger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/anilist_request-cli.log', Logger::NOTICE));
$container->setLogger($app_logger); $container->setLogger($app_logger);
$container->setLogger($anilistRequestLogger, 'anilist-request'); $container->setLogger($anilistRequestLogger, 'anilist-request');
$container->setLogger($kitsu_request_logger, 'kitsu-request'); $container->setLogger($kitsu_request_logger, 'kitsu-request');
// Create Config Object // Create Config Object
$container->set('config', static function() use ($configArray) { $container->set('config', static function() use ($configArray): Config {
return new Config($configArray); return new Config($configArray);
}); });
@ -126,7 +129,7 @@ class BaseCommand extends Command {
$_FILES $_FILES
); );
}); });
$container->set('response', static function() { $container->set('response', static function(): Response {
return new Response; return new Response;
}); });
@ -136,7 +139,7 @@ class BaseCommand extends Command {
}); });
// Models // Models
$container->set('kitsu-model', static function($container) { $container->set('kitsu-model', static function($container): Kitsu\Model {
$requestBuilder = new KitsuRequestBuilder(); $requestBuilder = new KitsuRequestBuilder();
$requestBuilder->setLogger($container->getLogger('kitsu-request')); $requestBuilder->setLogger($container->getLogger('kitsu-request'));
@ -152,7 +155,7 @@ class BaseCommand extends Command {
$model->setCache($cache); $model->setCache($cache);
return $model; return $model;
}); });
$container->set('anilist-model', static function ($container) { $container->set('anilist-model', static function ($container): Anilist\Model {
$requestBuilder = new Anilist\AnilistRequestBuilder(); $requestBuilder = new Anilist\AnilistRequestBuilder();
$requestBuilder->setLogger($container->getLogger('anilist-request')); $requestBuilder->setLogger($container->getLogger('anilist-request'));
@ -166,21 +169,21 @@ class BaseCommand extends Command {
return $model; return $model;
}); });
$container->set('settings-model', static function($container) { $container->set('settings-model', static function($container): Model\Settings {
$model = new Model\Settings($container->get('config')); $model = new Model\Settings($container->get('config'));
$model->setContainer($container); $model->setContainer($container);
return $model; return $model;
}); });
$container->set('auth', static function($container) { $container->set('auth', static function($container): Kitsu\Auth {
return new Kitsu\Auth($container); return new Kitsu\Auth($container);
}); });
$container->set('url-generator', static function($container) { $container->set('url-generator', static function($container): UrlGenerator {
return new UrlGenerator($container); return new UrlGenerator($container);
}); });
$container->set('util', static function($container) { $container->set('util', static function($container): Util {
return new Util($container); return new Util($container);
}); });

View File

@ -16,6 +16,9 @@
namespace Aviat\AnimeClient\Command; namespace Aviat\AnimeClient\Command;
use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException;
/** /**
* Clears the API Cache * Clears the API Cache
*/ */
@ -25,15 +28,15 @@ final class CacheClear extends BaseCommand {
* *
* @param array $args * @param array $args
* @param array $options * @param array $options
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
public function execute(array $args, array $options = []): void public function execute(array $args, array $options = []): void
{ {
$this->setContainer($this->setupContainer()); $this->setContainer($this->setupContainer());
$cache = $this->container->get('cache');
$cache->clear(); $this->container->get('cache')->clear();
$this->echoBox('API Cache has been cleared.'); $this->echoBox('API Cache has been cleared.');
} }

View File

@ -16,6 +16,9 @@
namespace Aviat\AnimeClient\Command; namespace Aviat\AnimeClient\Command;
use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException;
/** /**
* Clears the API Cache * Clears the API Cache
*/ */
@ -25,8 +28,8 @@ final class CachePrime extends BaseCommand {
* *
* @param array $args * @param array $args
* @param array $options * @param array $options
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
public function execute(array $args, array $options = []): void public function execute(array $args, array $options = []): void
@ -50,8 +53,9 @@ final class CachePrime extends BaseCommand {
$userIdItem->save(); $userIdItem->save();
} }
// Prime anime list cache
$kitsuModel = $this->container->get('kitsu-model'); $kitsuModel = $this->container->get('kitsu-model');
// Prime anime list cache
$kitsuModel->getFullOrganizedAnimeList(); $kitsuModel->getFullOrganizedAnimeList();
// Prime manga list cache // Prime manga list cache

View File

@ -16,8 +16,12 @@
namespace Aviat\AnimeClient\Command; namespace Aviat\AnimeClient\Command;
use Aviat\AnimeClient\API\ use Aviat\AnimeClient\API\{
{Anilist\MissingIdException, FailedResponseException, JsonAPI, ParallelAPIRequest}; Anilist\MissingIdException,
FailedResponseException,
JsonAPI,
ParallelAPIRequest
};
use Aviat\AnimeClient\API\Anilist\Transformer\{ use Aviat\AnimeClient\API\Anilist\Transformer\{
AnimeListTransformer as AALT, AnimeListTransformer as AALT,
MangaListTransformer as AMLT MangaListTransformer as AMLT

View File

@ -18,9 +18,19 @@ namespace Aviat\AnimeClient;
use function Aviat\Ion\_dir; use function Aviat\Ion\_dir;
use Aura\Router\Generator;
use Aura\Session\Segment;
use Aviat\AnimeClient\API\Kitsu\Auth;
use Aviat\Ion\ConfigInterface;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Aviat\Ion\Di\{ use Aviat\Ion\Di\{
ContainerAware, ContainerAware,
ContainerInterface ContainerInterface,
Exception\ContainerException,
Exception\NotFoundException
}; };
use Aviat\Ion\Exception\DoubleRenderException; use Aviat\Ion\Exception\DoubleRenderException;
use Aviat\Ion\View\{HtmlView, HttpView, JsonView}; use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
@ -35,31 +45,31 @@ class Controller {
/** /**
* The authentication object * The authentication object
* @var \Aviat\AnimeClient\API\Kitsu\Auth $auth ; * @var Auth $auth ;
*/ */
protected $auth; protected $auth;
/** /**
* Cache manager * Cache manager
* @var \Psr\Cache\CacheItemPoolInterface * @var CacheItemPoolInterface
*/ */
protected $cache; protected $cache;
/** /**
* The global configuration object * The global configuration object
* @var \Aviat\Ion\ConfigInterface $config * @var ConfigInterface $config
*/ */
public $config; public $config;
/** /**
* Request object * Request object
* @var \Psr\Http\Message\ServerRequestInterface $request * @var ServerRequestInterface $request
*/ */
protected $request; protected $request;
/** /**
* Response object * Response object
* @var \Psr\Http\Message\ResponseInterface $response * @var ResponseInterface $response
*/ */
public $response; public $response;
@ -71,13 +81,13 @@ class Controller {
/** /**
* Aura url generator * Aura url generator
* @var \Aura\Router\Generator * @var Generator
*/ */
protected $url; protected $url;
/** /**
* Session segment * Session segment
* @var \Aura\Session\Segment * @var Segment
*/ */
protected $session; protected $session;
@ -91,8 +101,8 @@ class Controller {
* Controller constructor. * Controller constructor.
* *
* @param ContainerInterface $container * @param ContainerInterface $container
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -127,8 +137,8 @@ class Controller {
* Set the current url in the session as the target of a future redirect * Set the current url in the session as the target of a future redirect
* *
* @param string|NULL $url * @param string|NULL $url
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
*/ */
public function setSessionRedirect(string $url = NULL): void public function setSessionRedirect(string $url = NULL): void
{ {
@ -167,8 +177,8 @@ class Controller {
* If one is not set, redirect to default url * If one is not set, redirect to default url
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
public function sessionRedirect(): void public function sessionRedirect(): void
@ -202,8 +212,8 @@ class Controller {
* @param string $template * @param string $template
* @param array $data * @param array $data
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
* @return string * @return string
*/ */
protected function loadPartial($view, string $template, array $data = []): string protected function loadPartial($view, string $template, array $data = []): string
@ -236,8 +246,8 @@ class Controller {
* @param string $template * @param string $template
* @param array $data * @param array $data
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
protected function renderFullPage($view, string $template, array $data): void protected function renderFullPage($view, string $template, array $data): void
@ -266,8 +276,8 @@ class Controller {
* @param string $title * @param string $title
* @param string $message * @param string $message
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
public function notFound( public function notFound(
@ -289,8 +299,8 @@ class Controller {
* @param string $message * @param string $message
* @param string $long_message * @param string $long_message
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
public function errorPage(int $httpCode, string $title, string $message, string $long_message = ''): void public function errorPage(int $httpCode, string $title, string $message, string $long_message = ''): void
@ -342,7 +352,7 @@ class Controller {
/** /**
* Helper for consistent page titles * Helper for consistent page titles
* *
* @param string[] $parts Title segments * @param string ...$parts Title segments
* @return string * @return string
*/ */
public function formatTitle(string ...$parts) : string public function formatTitle(string ...$parts) : string
@ -357,8 +367,8 @@ class Controller {
* @param string $type * @param string $type
* @param string $message * @param string $message
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
* @return string * @return string
*/ */
protected function showMessage($view, string $type, string $message): string protected function showMessage($view, string $type, string $message): string
@ -377,8 +387,8 @@ class Controller {
* @param HtmlView|null $view * @param HtmlView|null $view
* @param int $code * @param int $code
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200): void protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200): void

View File

@ -16,12 +16,15 @@
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use Aura\Router\Exception\RouteNotFound;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuWatchingStatus; use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuWatchingStatus;
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus; use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
use Aviat\AnimeClient\Types\FormItem; use Aviat\AnimeClient\Types\FormItem;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException;
use Aviat\Ion\Json; use Aviat\Ion\Json;
/** /**
@ -39,8 +42,8 @@ final class Anime extends BaseController {
* Constructor * Constructor
* *
* @param ContainerInterface $container * @param ContainerInterface $container
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -60,8 +63,8 @@ final class Anime extends BaseController {
* *
* @param string|int $type - The section of the list * @param string|int $type - The section of the list
* @param string $view - List or cover view * @param string $view - List or cover view
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void * @return void
*/ */
@ -104,9 +107,9 @@ final class Anime extends BaseController {
/** /**
* Form to add an anime * Form to add an anime
* *
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \Aura\Router\Exception\RouteNotFound * @throws RouteNotFound
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void * @return void
*/ */
@ -128,8 +131,8 @@ final class Anime extends BaseController {
/** /**
* Add an anime to the list * Add an anime to the list
* *
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
public function add(): void public function add(): void
@ -204,8 +207,8 @@ final class Anime extends BaseController {
/** /**
* Update an anime item via a form submission * Update an anime item via a form submission
* *
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return void * @return void
*/ */
public function formUpdate(): void public function formUpdate(): void
@ -292,8 +295,8 @@ final class Anime extends BaseController {
* View details of an anime * View details of an anime
* *
* @param string $animeId * @param string $animeId
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void * @return void
*/ */

View File

@ -16,12 +16,16 @@
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use Aura\Router\Exception\RouteNotFound;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\Model\{ use Aviat\AnimeClient\Model\{
Anime as AnimeModel, Anime as AnimeModel,
AnimeCollection as AnimeCollectionModel AnimeCollection as AnimeCollectionModel
}; };
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException;
use Aviat\Ion\Exception\DoubleRenderException;
/** /**
* Controller for Anime collection pages * Controller for Anime collection pages
@ -44,8 +48,8 @@ final class AnimeCollection extends BaseController {
* Constructor * Constructor
* *
* @param ContainerInterface $container * @param ContainerInterface $container
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -69,7 +73,7 @@ final class AnimeCollection extends BaseController {
/** /**
* Search for anime * Search for anime
* *
* @throws \Aviat\Ion\Exception\DoubleRenderException * @throws DoubleRenderException
* @return void * @return void
*/ */
public function search(): void public function search(): void
@ -83,8 +87,8 @@ final class AnimeCollection extends BaseController {
* Show the anime collection page * Show the anime collection page
* *
* @param string $view * @param string $view
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void * @return void
*/ */
@ -108,9 +112,9 @@ final class AnimeCollection extends BaseController {
* Show the anime collection add/edit form * Show the anime collection add/edit form
* *
* @param integer|null $id * @param integer|null $id
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \Aura\Router\Exception\RouteNotFound * @throws RouteNotFound
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void * @return void
*/ */
@ -138,8 +142,8 @@ final class AnimeCollection extends BaseController {
/** /**
* Update a collection item * Update a collection item
* *
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void * @return void
*/ */
@ -173,8 +177,8 @@ final class AnimeCollection extends BaseController {
/** /**
* Add a collection item * Add a collection item
* *
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void * @return void
*/ */

View File

@ -19,7 +19,7 @@ namespace Aviat\AnimeClient\Model;
/** /**
* Base model for api interaction * Base model for api interaction
*/ */
class API { abstract class API {
/** /**
* Sort the list entries by their title * Sort the list entries by their title
* *

View File

@ -16,6 +16,8 @@
namespace Aviat\AnimeClient\Model; namespace Aviat\AnimeClient\Model;
use Aviat\AnimeClient\API\Anilist\Model as AnilistModel;
use Aviat\AnimeClient\API\Kitsu\Model as KitsuModel;
use Aviat\AnimeClient\API\ParallelAPIRequest; use Aviat\AnimeClient\API\ParallelAPIRequest;
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus; use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
use Aviat\AnimeClient\Types\{ use Aviat\AnimeClient\Types\{
@ -41,14 +43,14 @@ class Anime extends API {
/** /**
* Model for making requests to Anilist API * Model for making requests to Anilist API
* *
* @var \Aviat\AnimeClient\API\Anilist\Model * @var AnilistModel
*/ */
protected $anilistModel; protected $anilistModel;
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* *
* @var \Aviat\AnimeClient\API\Kitsu\Model * @var KitsuModel
*/ */
protected $kitsuModel; protected $kitsuModel;

View File

@ -16,25 +16,94 @@
namespace Aviat\AnimeClient\Types; namespace Aviat\AnimeClient\Types;
use Aviat\AnimeClient\API\Kitsu\Enum\AnimeAiringStatus;
/** /**
* Type representing an anime within a watch list * Type representing an anime within a watch list
*/ */
class Anime extends AbstractType { class Anime extends AbstractType {
/**
* @var string
*/
public $age_rating; public $age_rating;
/**
* @var string
*/
public $age_rating_guide; public $age_rating_guide;
/**
* @var string
*/
public $cover_image; public $cover_image;
/**
* @var string|number
*/
public $episode_count; public $episode_count;
/**
* @var string|number
*/
public $episode_length; public $episode_length;
/**
* @var array
*/
public $genres; public $genres;
/**
* @var string
*/
public $id; public $id;
/**
* @var array
*/
public $included; public $included;
/**
* @var string
*/
public $show_type; public $show_type;
/**
* @var string
*/
public $slug; public $slug;
/**
* @var AnimeAiringStatus::NOT_YET_AIRED | AnimeAiringStatus::AIRING | AnimeAiringStatus::FINISHED_AIRING
*/
public $status; public $status;
/**
* @var array
*/
public $streaming_links; public $streaming_links;
/**
* @var string
*/
public $synopsis; public $synopsis;
/**
* @var string
*/
public $title; public $title;
/**
* @var array
*/
public $titles; public $titles;
/**
* @var string
*/
public $trailer_id; public $trailer_id;
/**
* @var string
*/
public $url; public $url;
} }

View File

@ -17,35 +17,147 @@
namespace Aviat\AnimeClient\Types; namespace Aviat\AnimeClient\Types;
class Config extends AbstractType { class Config extends AbstractType {
// ------------------------------------------------------------------------
// Config files/namespaces // Config files/namespaces
// ------------------------------------------------------------------------
/**
* @var Config\Anilist
*/
public $anilist; public $anilist;
/**
* @var Config\Cache
*/
public $cache; public $cache;
/**
* @var Config\Database
*/
public $database; public $database;
// ------------------------------------------------------------------------
// Settings in config.toml // Settings in config.toml
// ------------------------------------------------------------------------
/**
* @var string
*/
public $asset_path; // Path to public folder for urls public $asset_path; // Path to public folder for urls
/**
* @deprecated Use 'theme' instead
* @var bool
*/
public $dark_theme; /* Deprecated */ public $dark_theme; /* Deprecated */
/**
* Default Anime list status page, values are listed in
* Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Title
*
* @var string
*/
public $default_anime_list_path; public $default_anime_list_path;
/**
* The list to redirect to from the root url
*
* @var 'anime' | 'manga'
*/
public $default_list; public $default_list;
/**
* Default Manga list status page, values are listed in
* Aviat\AnimeClient\API\Enum\MangaReadingStatus\Title
*
* @var string
*/
public $default_manga_list_path; public $default_manga_list_path;
/**
* @var 'cover_view' | 'list_view'
*/
public $default_view_type; public $default_view_type;
/**
* @var string
*/
public $kitsu_username; public $kitsu_username;
/**
* @var bool
*/
public $secure_urls = TRUE; public $secure_urls = TRUE;
/**
* @var bool
*/
public $show_anime_collection; public $show_anime_collection;
public $show_manga_collection;
/**
* @var bool
*/
public $show_manga_collection = FALSE;
/**
* CSS theme: light, dark, or auto-switching
*
* @var 'auto' | 'light' | 'dark'
*/
public $theme; public $theme;
/**
* @var string
*/
public $whose_list; public $whose_list;
// ------------------------------------------------------------------------
// Application config // Application config
// ------------------------------------------------------------------------
/**
* @var array
*/
public $menus; public $menus;
/**
* @var array
*/
public $routes; public $routes;
// ------------------------------------------------------------------------
// Generated config values // Generated config values
// ------------------------------------------------------------------------
/**
* @var string
*/
public $asset_dir; // Path to public folder for local files public $asset_dir; // Path to public folder for local files
/**
* @var string
*/
public $base_config_dir; public $base_config_dir;
/**
* @var string
*/
public $config_dir; public $config_dir;
/**
* @var string
*/
public $data_cache_path; public $data_cache_path;
/**
* @var string
*/
public $img_cache_path; public $img_cache_path;
/**
* @var string
*/
public $view_path; public $view_path;
public function setAnilist ($data): void public function setAnilist ($data): void

View File

@ -19,14 +19,38 @@ namespace Aviat\AnimeClient\Types\Config;
use Aviat\AnimeClient\Types\AbstractType; use Aviat\AnimeClient\Types\AbstractType;
class Anilist extends AbstractType { class Anilist extends AbstractType {
/**
* @var bool
*/
public $enabled = FALSE; public $enabled = FALSE;
/**
* @var string
*/
public $client_id; public $client_id;
/**
* @var string
*/
public $client_secret; public $client_secret;
/**
* @var string
*/
public $access_token; public $access_token;
/**
* @var string
*/
public $access_token_expires; public $access_token_expires;
/**
* @var string
*/
public $refresh_token; public $refresh_token;
/**
* @var string
*/
public $username; public $username;
} }

View File

@ -19,8 +19,19 @@ namespace Aviat\AnimeClient\Types\Config;
use Aviat\AnimeClient\Types\AbstractType; use Aviat\AnimeClient\Types\AbstractType;
class Cache extends AbstractType { class Cache extends AbstractType {
/**
* @var string
*/
public $driver; public $driver;
/**
* @var array
*/
public $connection = []; public $connection = [];
/**
* @var array
*/
public $options = []; public $options = [];
/* public function setConnection($data): void /* public function setConnection($data): void

View File

@ -19,11 +19,38 @@ namespace Aviat\AnimeClient\Types\Config;
use Aviat\AnimeClient\Types\AbstractType; use Aviat\AnimeClient\Types\AbstractType;
class Database extends AbstractType { class Database extends AbstractType {
/**
* @var string
*/
public $type; public $type;
/**
* @var string
*/
public $host; public $host;
/**
* @var string
*/
public $user; public $user;
/**
* @var string
*/
public $pass; public $pass;
/**
* @var string|number
*/
public $port; public $port;
/**
* @var string
*/
public $database; public $database;
/**
* @var string
*/
public $file; public $file;
} }

View File

@ -20,7 +20,6 @@ use const Aviat\AnimeClient\SRC_DIR;
use function Aviat\Ion\_dir; use function Aviat\Ion\_dir;
use Aura\Web\WebFactory;
use Aviat\Ion\Json; use Aviat\Ion\Json;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Spatie\Snapshots\MatchesSnapshots; use Spatie\Snapshots\MatchesSnapshots;
@ -39,7 +38,6 @@ use Zend\Diactoros\{
class AnimeClientTestCase extends TestCase { class AnimeClientTestCase extends TestCase {
use MatchesSnapshots; use MatchesSnapshots;
// Test directory constants // Test directory constants
const ROOT_DIR = ROOT_DIR; const ROOT_DIR = ROOT_DIR;
const SRC_DIR = SRC_DIR; const SRC_DIR = SRC_DIR;