Merge pull request 'develop' (#37) from develop into master

Reviewed-on: timw4mail/HummingBirdAnimeClient#37
This commit is contained in:
Timothy Warren 2021-02-03 10:07:11 -05:00
commit df7a9e311b
202 changed files with 1413 additions and 1214 deletions

View File

@ -4,13 +4,12 @@ install:
- composer install --ignore-platform-reqs
php:
- 7.4
- nightly
script:
- mkdir -p build/logs
- php vendor/bin/phpunit -c build
matrix:
allow_failures:
- php: nightly
#matrix:
# allow_failures:
# - php: nightly

6
Jenkinsfile vendored
View File

@ -10,10 +10,10 @@ pipeline {
sh 'php composer.phar install --ignore-platform-reqs'
}
}
stage('PHP 7.4') {
stage('PHP 8') {
agent {
docker {
image 'php:7.4-alpine'
image 'php:8-cli-alpine'
args '-u root --privileged'
}
}
@ -25,7 +25,7 @@ pipeline {
stage('Latest PHP') {
agent {
docker {
image 'php:alpine'
image 'php:cli-alpine'
args '-u root --privileged'
}
}

View File

@ -30,7 +30,7 @@ class RoboFile extends Tasks {
*
* @var array
*/
protected $taskDirs = [
protected array $taskDirs = [
'build/logs',
'build/pdepend',
'build/phpdox',
@ -41,7 +41,7 @@ class RoboFile extends Tasks {
*
* @var array
*/
protected $cleanDirs = [
protected array $cleanDirs = [
'coverage',
'docs',
'phpdoc',

View File

@ -14,7 +14,7 @@
* @link https://github.com/timw4mail/HummingBirdAnimeClient
*/
use function Aviat\AnimeClient\loadToml;
use function Aviat\AnimeClient\loadConfig;
// ----------------------------------------------------------------------------
// Lower level configuration
@ -24,7 +24,7 @@ use function Aviat\AnimeClient\loadToml;
$APP_DIR = realpath(__DIR__ . '/../');
$ROOT_DIR = realpath("{$APP_DIR}/../");
$tomlConfig = loadToml(__DIR__);
$tomlConfig = loadConfig(__DIR__);
return array_merge($tomlConfig, [
'asset_dir' => "{$ROOT_DIR}/public",

View File

@ -51,6 +51,10 @@ $routes = [
'action' => 'add',
'verb' => 'post',
],
'anime.random' => [
'path' => '/anime/details/random',
'action' => 'random',
],
'anime.details' => [
'path' => '/anime/details/{id}',
'action' => 'details',
@ -84,6 +88,10 @@ $routes = [
'action' => 'delete',
'verb' => 'post',
],
'manga.random' => [
'path' => '/manga/details/random',
'action' => 'random',
],
'manga.details' => [
'path' => '/manga/details/{id}',
'action' => 'details',
@ -247,6 +255,13 @@ $routes = [
'path' => '/logout',
'action' => 'logout',
],
'history' => [
'controller' => 'history',
'path' => '/history/{type}',
'tokens' => [
'type' => SLUG_PATTERN
]
],
'increment' => [
'path' => '/{controller}/increment',
'action' => 'increment',
@ -280,19 +295,12 @@ $routes = [
],
],
'list' => [
'path' => '/{controller}/{type}{/view}',
'path' => '/{controller}/{status}{/view}',
'tokens' => [
'type' => ALPHA_SLUG_PATTERN,
'status' => ALPHA_SLUG_PATTERN,
'view' => ALPHA_SLUG_PATTERN,
],
],
'history' => [
'controller' => 'history',
'path' => '/history/{type}',
'tokens' => [
'type' => SLUG_PATTERN
]
],
'index_redirect' => [
'path' => '/',
'action' => 'redirectToDefaultRoute',

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -32,10 +32,13 @@ use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Psr\SimpleCache\CacheInterface;
use function Aviat\Ion\_dir;
if ( ! defined('APP_DIR'))
{
define('APP_DIR', __DIR__);
define('TEMPLATE_DIR', APP_DIR . '/templates');
define('ROOT_DIR', dirname(APP_DIR));
define('TEMPLATE_DIR', _dir(APP_DIR, 'templates'));
}
// -----------------------------------------------------------------------------
@ -47,15 +50,16 @@ return static function (array $configArray = []): Container {
// -------------------------------------------------------------------------
// Logging
// -------------------------------------------------------------------------
$LOG_DIR = _dir(APP_DIR, 'logs');
$appLogger = new Logger('animeclient');
$appLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', 2, Logger::WARNING));
$appLogger->pushHandler(new RotatingFileHandler(_dir($LOG_DIR, 'app.log'), 2, Logger::WARNING));
$container->setLogger($appLogger);
foreach (['anilist-request', 'kitsu-request', 'kitsu-graphql'] as $channel)
{
$logger = new Logger($channel);
$handler = new RotatingFileHandler(__DIR__ . "/logs/{$channel}.log", 2, Logger::WARNING);
$handler = new RotatingFileHandler(_dir($LOG_DIR, "{$channel}.log"), 2, Logger::WARNING);
$handler->setFormatter(new JsonFormatter());
$logger->pushHandler($handler);
@ -67,7 +71,7 @@ return static function (array $configArray = []): Container {
// -------------------------------------------------------------------------
// Create Config Object
$container->set('config', fn () => new Config($configArray));
$container->set('config', static fn () => new Config($configArray));
// Create Cache Object
$container->set('cache', static function(ContainerInterface $container): CacheInterface {
@ -77,7 +81,7 @@ return static function (array $configArray = []): Container {
});
// Create Aura Router Object
$container->set('aura-router', fn() => new RouterContainer);
$container->set('aura-router', static fn() => new RouterContainer);
// Create Html helpers
$container->set('html-helper', static function(ContainerInterface $container) {
@ -125,8 +129,8 @@ return static function (array $configArray = []): Container {
});
// Create Request Object
$container->set('request', fn () => ServerRequestFactory::fromGlobals(
$_SERVER,
$container->set('request', static fn () => ServerRequestFactory::fromGlobals(
$GLOBALS['_SERVER'],
$_GET,
$_POST,
$_COOKIE,
@ -134,10 +138,10 @@ return static function (array $configArray = []): Container {
));
// Create session Object
$container->set('session', fn () => (new SessionFactory())->newInstance($_COOKIE));
$container->set('session', static fn () => (new SessionFactory())->newInstance($_COOKIE));
// Miscellaneous helper methods
$container->set('util', fn ($container) => new Util($container));
$container->set('util', static fn ($container) => new Util($container));
// Models
$container->set('kitsu-model', static function(ContainerInterface $container): Kitsu\Model {
@ -170,10 +174,10 @@ return static function (array $configArray = []): Container {
return $model;
});
$container->set('anime-model', fn ($container) => new Model\Anime($container));
$container->set('manga-model', fn ($container) => new Model\Manga($container));
$container->set('anime-collection-model', fn ($container) => new Model\AnimeCollection($container));
$container->set('manga-collection-model', fn ($container) => new Model\MangaCollection($container));
$container->set('anime-model', static fn ($container) => new Model\Anime($container));
$container->set('manga-model', static fn ($container) => new Model\Manga($container));
$container->set('anime-collection-model', static fn ($container) => new Model\AnimeCollection($container));
$container->set('manga-collection-model', static fn ($container) => new Model\MangaCollection($container));
$container->set('settings-model', static function($container) {
$model = new Model\Settings($container->get('config'));
$model->setContainer($container);
@ -181,13 +185,13 @@ return static function (array $configArray = []): Container {
});
// Miscellaneous Classes
$container->set('auth', fn ($container) => new Kitsu\Auth($container));
$container->set('url-generator', fn ($container) => new UrlGenerator($container));
$container->set('auth', static fn ($container) => new Kitsu\Auth($container));
$container->set('url-generator', static fn ($container) => new UrlGenerator($container));
// -------------------------------------------------------------------------
// Dispatcher
// -------------------------------------------------------------------------
$container->set('dispatcher', fn ($container) => new Dispatcher($container));
$container->set('dispatcher', static fn ($container) => new Dispatcher($container));
return $container;
};

View File

@ -18,7 +18,7 @@
</a>
</div>
<div class="table">
<?php if ($item['private'] || $item['rewatching']): ?>
<?php if (isset($item['private']) || isset($item['rewatching'])): ?>
<div class="row">
<?php foreach (['private', 'rewatching'] as $attr): ?>
<?php if ($item[$attr]): ?>

View File

@ -5,8 +5,8 @@ namespace Aviat\AnimeClient;
$whose = $config->get('whose_list') . "'s ";
$lastSegment = $urlGenerator->lastSegment();
$extraSegment = $lastSegment === 'list' ? '/list' : '';
$hasAnime = stripos($_SERVER['REQUEST_URI'], 'anime') !== FALSE;
$hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE;
$hasAnime = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'anime') !== FALSE;
$hasManga = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'manga') !== FALSE;
?>
<div id="main-nav" class="flex flex-align-end flex-wrap">
@ -84,7 +84,7 @@ $hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE;
<?php if ($container->get('util')->isViewPage() && ($hasAnime || $hasManga)): ?>
<nav>
<?= $helper->menu($menu_name) ?>
<?php if (stripos($_SERVER['REQUEST_URI'], 'history') === FALSE): ?>
<?php if (stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'history') === FALSE): ?>
<br />
<ul>
<?php $currentView = Util::eq('list', $lastSegment) ? 'list' : 'cover' ?>

View File

@ -3,13 +3,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -1,29 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="../tests/bootstrap.php"
beStrictAboutTestsThatDoNotTestAnything="true"
>
<filter>
<whitelist>
<directory suffix=".php">../src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="AnimeClient">
<directory>../tests</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="../coverage"/>
<log type="coverage-clover" target="logs/clover.xml"/>
</logging>
<php>
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0" />
<server name="HTTP_HOST" value="localhost" />
<server name="SERVER_NAME" value="localhost" />
<server name="REQUEST_URI" value="/" />
<server name="REQUEST_METHOD" value="GET" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" stopOnFailure="false" bootstrap="../tests/bootstrap.php" beStrictAboutTestsThatDoNotTestAnything="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">../src</directory>
</include>
<report>
<clover outputFile="logs/clover.xml"/>
<html outputDirectory="../coverage"/>
</report>
</coverage>
<testsuites>
<testsuite name="AnimeClient">
<directory>../tests/AnimeClient</directory>
</testsuite>
<testsuite name="Ion">
<directory>../tests/Ion</directory>
</testsuite>
</testsuites>
<logging/>
<php>
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0"/>
<server name="HTTP_HOST" value="localhost"/>
<server name="SERVER_NAME" value="localhost"/>
<server name="REQUEST_URI" value="/"/>
<server name="REQUEST_METHOD" value="GET"/>
</php>
</phpunit>

View File

@ -30,7 +30,7 @@
"config": {
"lock": false,
"platform": {
"php": "7.4"
"php": "8"
}
},
"require": {
@ -48,31 +48,30 @@
"ext-json": "*",
"ext-gd": "*",
"ext-pdo": "*",
"laminas/laminas-diactoros": "^2.2.3",
"filp/whoops": "^2.1",
"laminas/laminas-diactoros": "^2.5.0",
"laminas/laminas-httphandlerrunner": "^1.1.0",
"maximebf/consolekit": "^1.0.3",
"monolog/monolog": "^2.0.2",
"php": ">=7.4",
"php": "^8.0.0",
"psr/container": "^1.0.0",
"psr/http-message": "^1.0.1",
"psr/log": "^1.1.3",
"robmorgan/phinx": "^0.12.4",
"symfony/var-dumper": "^5.0.7",
"yosymfony/toml": "^1.0.4"
},
"require-dev": {
"consolidation/robo": "^2.0.0",
"filp/whoops": "^2.1",
"pdepend/pdepend": "^2.",
"phploc/phploc": "^5.0.0",
"phploc/phploc": "^7.0.0",
"phpmd/phpmd": "^2.8.2",
"phpstan/phpstan": "^0.12.19",
"phpunit/phpunit": "^8.5.2",
"phpunit/phpunit": "^9.5.0",
"roave/security-advisories": "dev-master",
"robmorgan/phinx": "^0.12.4",
"sebastian/phpcpd": "^4.1.0",
"sebastian/phpcpd": "^6.0.0",
"spatie/phpunit-snapshot-assertions": "^4.1.0",
"squizlabs/php_codesniffer": "^3.5.4",
"symfony/var-dumper": "^5.0.7",
"theseer/phpdox": "^0.12.0"
"squizlabs/php_codesniffer": "^3.5.4"
},
"scripts": {
"build": "vendor/bin/robo build",

View File

@ -7,7 +7,7 @@ require_once __DIR__ . '/vendor/autoload.php';
use Aviat\AnimeClient\Command;
use ConsoleKit\Console;
$_SERVER['HTTP_HOST'] = 'localhost';
$GLOBALS['_SERVER']['HTTP_HOST'] = 'localhost';
define('APP_DIR', __DIR__ . '/app');
define('TEMPLATE_DIR', APP_DIR . '/templates');

View File

@ -1,6 +1,6 @@
<?php
$verb = strtolower($_SERVER['REQUEST_METHOD']);
$verb = strtolower($GLOBALS['_SERVER']['REQUEST_METHOD']);
// Send request method if nothing else is specified
if (empty($_GET))

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -45,7 +45,7 @@ $CONF_DIR = _dir($APP_DIR, 'config');
$baseConfig = require "{$APPCONF_DIR}/base_config.php";
$di = require "{$APP_DIR}/bootstrap.php";
$config = loadToml($CONF_DIR);
$config = loadConfig($CONF_DIR);
$overrideFile = "{$CONF_DIR}/admin-override.toml";
$overrideConfig = file_exists($overrideFile)

View File

@ -1,24 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="AnimeClient">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0" />
<server name="HTTP_HOST" value="localhost" />
<server name="SERVER_NAME" value="localhost" />
<server name="REQUEST_URI" value="/" />
<server name="REQUEST_METHOD" value="GET" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" stopOnFailure="false" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="AnimeClient">
<directory>tests/AnimeClient</directory>
</testsuite>
<testsuite name="Ion">
<directory>tests/Ion</directory>
</testsuite>
</testsuites>
<php>
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0"/>
<server name="HTTP_HOST" value="localhost"/>
<server name="SERVER_NAME" value="localhost"/>
<server name="REQUEST_URI" value="/"/>
<server name="REQUEST_METHOD" value="GET"/>
</php>
</phpunit>

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -35,43 +35,36 @@ abstract class APIRequestBuilder {
/**
* Where to look for GraphQL request files
* @var string
*/
protected string $filePath = __DIR__;
protected string $filePath = '';
/**
* Url prefix for making url requests
* @var string
*/
protected string $baseUrl = '';
/**
* Url path of the request
* @var string
*/
protected string $path = '';
/**
* Query string for the request
* @var string
*/
protected string $query = '';
/**
* Default request headers
* @var array
*/
protected array $defaultHeaders = [];
/**
* Valid HTTP request methods
* @var array
*/
protected array $validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];
/**
* The current request
* @var Request
*/
protected Request $request;
@ -309,7 +302,7 @@ abstract class APIRequestBuilder {
*/
public function queryRequest(string $name, array $variables = []): Request
{
$file = "{$this->filePath}/Queries/{$name}.graphql";
$file = realpath("{$this->filePath}/Queries/{$name}.graphql");
if ( ! file_exists($file))
{
throw new LogicException('GraphQL query file does not exist.');

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -21,7 +21,7 @@ use function Amp\Promise\wait;
use InvalidArgumentException;
use Amp\Http\Client\Request;
use Aviat\AnimeClient\API\Anilist;
use Aviat\AnimeClient\Anilist;
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
use Aviat\AnimeClient\Types\FormItem;
use Aviat\Ion\Json;

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -18,7 +18,7 @@ namespace Aviat\AnimeClient\API\Anilist;
use Amp\Http\Client\Request;
use Amp\Http\Client\Response;
use Aviat\AnimeClient\API\Anilist;
use Aviat\AnimeClient\Anilist;
use Aviat\Ion\Di\ContainerAware;
use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Json;

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -23,7 +23,6 @@ trait RequestBuilderTrait {
/**
* The request builder for the Anilist API
* @var RequestBuilder
*/
protected RequestBuilder $requestBuilder;
@ -33,7 +32,7 @@ trait RequestBuilderTrait {
* @param RequestBuilder $requestBuilder
* @return self
*/
public function setRequestBuilder($requestBuilder): self
public function setRequestBuilder(RequestBuilder $requestBuilder): self
{
$this->requestBuilder = $requestBuilder;
return $this;

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -24,33 +24,15 @@ class MediaListEntry extends AbstractType {
*/
public $id;
/**
* @var string|null
*/
public ?string $notes;
/**
* @var bool
*/
public ?bool $private;
/**
* @var int
*/
public int $progress;
/**
* @var int
*/
public ?int $repeat;
/**
* @var string
*/
public string $status;
/**
* @var int
*/
public ?int $score;
}

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -33,7 +33,7 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\{
MangaListTransformer,
MangaTransformer
};
use Aviat\AnimeClient\Enum\ListType;
use Aviat\AnimeClient\Enum\MediaType;
use Aviat\AnimeClient\Kitsu as K;
use Aviat\AnimeClient\Types\Anime;
use Aviat\AnimeClient\Types\MangaPage;
@ -256,6 +256,21 @@ final class Model {
return $this->animeTransformer->transform($baseData);
}
public function getRandomAnime(): Anime
{
$baseData = $this->requestBuilder->runQuery('RandomMedia', [
'type' => 'ANIME'
]);
return $this->animeTransformer->transform($baseData);
}
public function getRandomLibraryAnime(string $status): Anime
{
// @TODO
return Anime::from([]);
}
/**
* Get information about a particular anime
*
@ -310,7 +325,7 @@ final class Model {
if ($list === NULL)
{
$data = $this->getList(ListType::ANIME, $status) ?? [];
$data = $this->getList(MediaType::ANIME, $status) ?? [];
// Bail out on no data
if (empty($data))
@ -343,7 +358,7 @@ final class Model {
*/
public function getAnimeListCount(string $status = '') : int
{
return $this->getListCount(ListType::ANIME, $status);
return $this->getListCount(MediaType::ANIME, $status);
}
/**
@ -392,6 +407,15 @@ final class Model {
return $this->mangaTransformer->transform($baseData);
}
public function getRandomManga(): MangaPage
{
$baseData = $this->requestBuilder->runQuery('RandomMedia', [
'type' => 'MANGA'
]);
return $this->mangaTransformer->transform($baseData);
}
/**
* Get information about a particular manga
*
@ -444,7 +468,7 @@ final class Model {
if ($list === NULL)
{
$data = $this->getList(ListType::MANGA, $status) ?? [];
$data = $this->getList(MediaType::MANGA, $status) ?? [];
// Bail out on no data
if (empty($data))
@ -477,7 +501,7 @@ final class Model {
*/
public function getMangaListCount(string $status = '') : int
{
return $this->getListCount(ListType::MANGA, $status);
return $this->getListCount(MediaType::MANGA, $status);
}
/**

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -0,0 +1,134 @@
query ($type: MediaTypeEnum!) {
randomMedia(mediaType: $type, ageRatings: [G,PG,R]) {
id
ageRating
ageRatingGuide
posterImage {
original {
height
name
url
width
}
views {
height
name
url
width
}
}
categories(first: 100) {
nodes {
title
}
}
characters(first: 100) {
nodes {
character {
id
names {
alternatives
canonical
localized
}
image {
original {
height
name
url
width
}
}
slug
}
role
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
description
startDate
endDate
sfw
slug
mappings(first: 10) {
nodes {
externalId
externalSite
}
}
staff(first: 100) {
nodes {
person {
id
birthday
image {
original {
height
name
url
width
}
views {
height
name
url
width
}
}
names {
alternatives
canonical
localized
}
slug
}
role
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
status
titles {
alternatives
canonical
canonicalLocale
localized
}
...on Anime {
episodeCount
episodeLength
totalLength
season
streamingLinks(first: 10) {
nodes {
dubs
subs
regions
streamer {
id
siteName
}
url
}
}
subtype
totalLength
youtubeTrailerVideoId
}
...on Manga {
chapterCount
volumeCount
subtype
}
}
}

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -34,9 +34,7 @@ final class AnimeTransformer extends AbstractTransformer {
*/
public function transform($item): AnimePage
{
$base = array_key_exists('findAnimeBySlug', $item['data'])
? $item['data']['findAnimeBySlug']
: $item['data']['findAnimeById'];
$base = $item['data']['findAnimeBySlug'] ?? $item['data']['findAnimeById'] ?? $item['data']['randomMedia'];
$characters = [];
$links = [];
$staff = [];

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -34,10 +34,7 @@ final class MangaTransformer extends AbstractTransformer {
*/
public function transform($item): MangaPage
{
$base = array_key_exists('findMangaBySlug', $item['data'])
? $item['data']['findMangaBySlug']
: $item['data']['findMangaById'];
$base = $item['data']['findMangaBySlug'] ?? $item['data']['findMangaById'] ?? $item['data']['randomMedia'];
$characters = [];
$links = [];
$staff = [];

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -152,8 +152,6 @@ interface Media {
"Returns the last _n_ elements from the list."
last: Int
): MediaReactionConnection!
"The season this was released in"
season: ReleaseSeasonEnum
"Whether the media is Safe-for-Work"
sfw: Boolean!
"The URL-friendly identifier of this media"
@ -241,6 +239,8 @@ type Account implements WithTimestamps {
ratingSystem: RatingSystemEnum!
"Whether Not Safe For Work content is accessible"
sfwFilter: Boolean
"The site-wide permissions this user has access to"
sitePermissions: [SitePermissionEnum!]!
"Time zone of the account"
timeZone: String
"Preferred language for media titles"
@ -921,6 +921,8 @@ type Library {
last: Int,
mediaType: MediaTypeEnum!
): LibraryEntryConnection!
"Random anime or manga from this library"
randomMedia(mediaType: MediaTypeEnum!, status: [LibraryEntryStatusEnum!]!): Media
}
"Information about a specific media entry for a user"
@ -1143,6 +1145,13 @@ type LibraryEventEdge {
node: LibraryEvent
}
"Autogenerated return type of LockPost"
type LockPostPayload {
"Graphql Errors"
errors: [Generic!]
post: Post
}
type Manga implements Media & WithTimestamps {
"The recommended minimum age group for this media"
ageRating: AgeRatingEnum
@ -1245,8 +1254,6 @@ type Manga implements Media & WithTimestamps {
"Returns the last _n_ elements from the list."
last: Int
): MediaReactionConnection!
"The season this was released in"
season: ReleaseSeasonEnum
"Whether the media is Safe-for-Work"
sfw: Boolean!
"The URL-friendly identifier of this media"
@ -1464,14 +1471,14 @@ type MediaEdge {
"The role a company played in the creation or localization of a media"
type MediaProduction implements WithTimestamps {
"The production company"
company: Producer!
createdAt: ISO8601DateTime!
id: ID!
"The media"
media: Media!
"The producer"
person: Producer!
"The role this company played"
role: String!
role: MediaProductionRoleEnum!
updatedAt: ISO8601DateTime!
}
@ -1581,6 +1588,7 @@ type Mutation {
episode: EpisodeMutation
libraryEntry: LibraryEntryMutation
mapping: MappingMutation
post: PostMutation
pro: ProMutation!
}
@ -1684,6 +1692,12 @@ type Post implements WithTimestamps {
"Returns the last _n_ elements from the list."
last: Int
): ProfileConnection!
"When this post was locked."
lockedAt: ISO8601DateTime
"The user who locked this post."
lockedBy: Profile
"The reason why this post was locked."
lockedReason: LockedReasonEnum
"The media tagged in this post."
media: Media
updatedAt: ISO8601DateTime!
@ -1709,6 +1723,19 @@ type PostEdge {
node: Post
}
type PostMutation {
"Lock a Post."
lock(
"Lock a Post."
input: LockInput!
): LockPostPayload
"Unlock a Post."
unlock(
"Unlock a Post."
input: UnlockInput!
): UnlockPostPayload
}
type ProMutation {
"Set the user's discord tag"
setDiscord(
@ -1966,6 +1993,8 @@ type Query {
findPersonById(id: ID!): Person
"Find a single Person by Slug"
findPersonBySlug(slug: String!): Person
"Find a single Post by ID"
findPostById(id: ID!): Post
"Find a single User by ID"
findProfileById(id: ID!): Profile
"Find a single User by Slug"
@ -2055,6 +2084,8 @@ type Query {
"Returns the last _n_ elements from the list."
last: Int
): ProfileConnection!
"Random anime or manga"
randomMedia(ageRatings: [AgeRatingEnum!]!, mediaType: MediaTypeEnum!): Media!
"Search for Anime by title using Algolia. The most relevant results will be at the top."
searchAnimeByTitle(
"Returns the elements in the list that come after the specified cursor."
@ -2079,7 +2110,7 @@ type Query {
last: Int,
title: String!
): MangaConnection!
"Search for any media (Anime, Manga) by title using Algolia. The most relevant results will be at the top."
"Search for any media (Anime, Manga) by title using Algolia. If no media_type is supplied, it will search for both. The most relevant results will be at the top."
searchMediaByTitle(
"Returns the elements in the list that come after the specified cursor."
after: String,
@ -2089,8 +2120,22 @@ type Query {
first: Int,
"Returns the last _n_ elements from the list."
last: Int,
"Dynamically choose a specific media_type. If left blank, it will return results for both."
mediaType: MediaTypeEnum,
title: String!
): MediaConnection!
"Search for User by username using Algolia. The most relevant results will be at the top."
searchProfileByUsername(
"Returns the elements in the list that come after the specified cursor."
after: String,
"Returns the elements in the list that come before the specified cursor."
before: String,
"Returns the first _n_ elements from the list."
first: Int,
"Returns the last _n_ elements from the list."
last: Int,
username: String!
): ProfileConnection
"Get your current session info"
session: Session!
}
@ -2172,6 +2217,8 @@ type QuoteLineEdge {
type Session {
"The account associated with this session"
account: Account
"Single sign-on token for Nolt"
noltToken: String!
"The profile associated with this session"
profile: Profile
}
@ -2302,6 +2349,13 @@ type TitlesList {
localized(locales: [String!]): Map!
}
"Autogenerated return type of UnlockPost"
type UnlockPostPayload {
"Graphql Errors"
errors: [Generic!]
post: Post
}
"Autogenerated return type of Unsubscribe"
type UnsubscribePayload {
"Graphql Errors"
@ -2436,6 +2490,12 @@ enum LibraryEventKindEnum {
UPDATED
}
enum LockedReasonEnum {
CLOSED
SPAM
TOO_HEATED
}
enum MangaSubtypeEnum {
"Self published work."
DOUJIN
@ -2481,6 +2541,13 @@ enum MappingItemEnum {
PRODUCER
}
enum MediaProductionRoleEnum {
LICENSOR
PRODUCER
SERIALIZATION
STUDIO
}
"これはアニメやマンガです"
enum MediaTypeEnum {
ANIME
@ -2542,6 +2609,15 @@ enum ReleaseStatusEnum {
UPCOMING
}
enum SitePermissionEnum {
"Administrator/staff member of Kitsu"
ADMIN
"Moderator of community behavior"
COMMUNITY_MOD
"Maintainer of the Kitsu media database"
DATABASE_MOD
}
enum TitleLanguagePreferenceEnum {
"Prefer the most commonly-used title for media"
CANONICAL
@ -2672,6 +2748,11 @@ input LibraryEntryUpdateStatusByMediaInput {
status: LibraryEntryStatusEnum!
}
input LockInput {
id: ID!
lockedReason: LockedReasonEnum!
}
input MappingCreateInput {
externalId: ID!
externalSite: MappingExternalSiteEnum!
@ -2693,6 +2774,10 @@ input TitlesListInput {
localized: Map
}
input UnlockInput {
id: ID!
}
"A date, expressed as an ISO8601 string"
scalar Date

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,17 +4,17 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API;
namespace Aviat\AnimeClient;
use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\Kitsu as KAWS,
@ -64,28 +64,4 @@ final class Anilist {
MangaReadingStatus::DROPPED => KMRS::DROPPED,
MangaReadingStatus::PLAN_TO_READ => KMRS::PLAN_TO_READ,
];
public static function getIdToWatchingStatusMap(): array
{
return [
'CURRENT' => AnimeWatchingStatus::WATCHING,
'COMPLETED' => AnimeWatchingStatus::COMPLETED,
'PAUSED' => AnimeWatchingStatus::ON_HOLD,
'DROPPED' => AnimeWatchingStatus::DROPPED,
'PLANNING' => AnimeWatchingStatus::PLAN_TO_WATCH,
'REPEATING' => AnimeWatchingStatus::WATCHING,
];
}
public static function getIdToReadingStatusMap(): array
{
return [
'CURRENT' => MangaReadingStatus::READING,
'COMPLETED' => MangaReadingStatus::COMPLETED,
'PAUSED' => MangaReadingStatus::ON_HOLD,
'DROPPED' => MangaReadingStatus::DROPPED,
'PLANNING' => MangaReadingStatus::PLAN_TO_READ,
'REPEATING' => MangaReadingStatus::READING,
];
}
}

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -19,7 +19,6 @@ namespace Aviat\AnimeClient;
use Aviat\AnimeClient\Kitsu;
use Psr\SimpleCache\CacheInterface;
use Psr\SimpleCache\InvalidArgumentException;
use function Amp\Promise\wait;
use Amp\Http\Client\Request;
use Amp\Http\Client\Response;
@ -31,6 +30,8 @@ use Yosymfony\Toml\{Toml, TomlBuilder};
use Throwable;
use function Amp\Promise\wait;
use function Aviat\Ion\_dir;
// ----------------------------------------------------------------------------
//! TOML Functions
// ----------------------------------------------------------------------------
@ -38,10 +39,11 @@ use Throwable;
/**
* Load configuration options from .toml files
*
* @codeCoverageIgnore
* @param string $path - Path to load config
* @return array
*/
function loadToml(string $path): array
function loadConfig(string $path): array
{
$output = [];
$files = glob("{$path}/*.toml");
@ -75,6 +77,7 @@ function loadToml(string $path): array
/**
* Load config from one specific TOML file
*
* @codeCoverageIgnore
* @param string $filename
* @return array
*/
@ -83,6 +86,36 @@ function loadTomlFile(string $filename): array
return Toml::parseFile($filename);
}
function _iterateToml(TomlBuilder $builder, iterable $data, $parentKey = NULL): void
{
foreach ($data as $key => $value)
{
// Skip unsupported empty value
if ($value === NULL)
{
continue;
}
if (is_scalar($value) || isSequentialArray($value))
{
$builder->addValue($key, $value);
continue;
}
$newKey = ($parentKey !== NULL)
? "{$parentKey}.{$key}"
: $key;
if ( ! isSequentialArray($value))
{
$builder->addTable($newKey);
}
_iterateToml($builder, $value, $newKey);
}
}
/**
* Serialize config data into a Toml file
*
@ -92,35 +125,6 @@ function loadTomlFile(string $filename): array
function arrayToToml(iterable $data): string
{
$builder = new TomlBuilder();
function _iterateToml(TomlBuilder $builder, iterable $data, $parentKey = NULL): void
{
foreach ($data as $key => $value)
{
if ($value === NULL)
{
continue;
}
if (is_scalar($value) || isSequentialArray($value))
{
// $builder->addTable('');
$builder->addValue($key, $value);
continue;
}
$newKey = ($parentKey !== NULL)
? "{$parentKey}.{$key}"
: $key;
if ( ! isSequentialArray($value))
{
$builder->addTable($newKey);
}
_iterateToml($builder, $value, $newKey);
}
}
_iterateToml($builder, $data);
@ -177,9 +181,11 @@ function checkFolderPermissions(ConfigInterface $config): array
$errors = [];
$publicDir = $config->get('asset_dir');
$APP_DIR = _dir(dirname(__DIR__, 2), '/app');
$pathMap = [
'app/config' => realpath(__DIR__ . '/../../app/config'),
'app/logs' => realpath(__DIR__ . '/../../app/logs'),
'app/config' => "{$APP_DIR}/config",
'app/logs' => "{$APP_DIR}/logs",
'public/images/avatars' => "{$publicDir}/images/avatars",
'public/images/anime' => "{$publicDir}/images/anime",
'public/images/characters' => "{$publicDir}/images/characters",
@ -231,7 +237,7 @@ function getApiClient (): HttpClient
* @return Response
* @throws Throwable
*/
function getResponse ($request): Response
function getResponse (Request|string $request): Response
{
$client = getApiClient();
@ -250,7 +256,7 @@ function getResponse ($request): Response
* @param bool $webp
* @return string
*/
function getLocalImg ($kitsuUrl, $webp = TRUE): string
function getLocalImg (string $kitsuUrl, $webp = TRUE): string
{
if (empty($kitsuUrl) || ( ! is_string($kitsuUrl)))
{
@ -282,11 +288,11 @@ function getLocalImg ($kitsuUrl, $webp = TRUE): string
* Create a transparent placeholder image
*
* @param string $path
* @param int $width
* @param int $height
* @param int|null $width
* @param int|null $height
* @param string $text
*/
function createPlaceholderImage ($path, ?int $width, ?int $height, $text = 'Image Unavailable'): void
function createPlaceholderImage (string $path, ?int $width, ?int $height, $text = 'Image Unavailable'): void
{
$width = $width ?? 200;
$height = $height ?? 200;
@ -339,7 +345,7 @@ function createPlaceholderImage ($path, ?int $width, ?int $height, $text = 'Imag
*/
function colNotEmpty(array $search, string $key): bool
{
$items = array_filter(array_column($search, $key), fn ($x) => ( ! empty($x)));
$items = array_filter(array_column($search, $key), static fn ($x) => ( ! empty($x)));
return count($items) > 0;
}
@ -358,9 +364,9 @@ function clearCache(CacheInterface $cache): bool
Kitsu::AUTH_TOKEN_CACHE_KEY,
Kitsu::AUTH_TOKEN_EXP_CACHE_KEY,
Kitsu::AUTH_TOKEN_REFRESH_CACHE_KEY,
], NULL);
]);
$userData = array_filter((array)$userData, fn ($value) => $value !== NULL);
$userData = array_filter((array)$userData, static fn ($value) => $value !== NULL);
$cleared = $cache->clear();
$saved = ( ! empty($userData))
@ -373,6 +379,7 @@ function clearCache(CacheInterface $cache): bool
/**
* Render a PHP code template as a string
*
* @codeCoverageIgnore
* @param string $path
* @param array $data
* @return string

View File

@ -4,20 +4,24 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Command;
use Monolog\Formatter\JsonFormatter;
use function Aviat\AnimeClient\loadToml;
use function Aviat\Ion\_dir;
use const Aviat\AnimeClient\SRC_DIR;
use function Aviat\AnimeClient\loadConfig;
use function Aviat\AnimeClient\loadTomlFile;
use Aura\Router\RouterContainer;
@ -108,14 +112,14 @@ abstract class BaseCommand extends Command {
*/
public function setupContainer(): ContainerInterface
{
$APP_DIR = realpath(__DIR__ . '/../../../app');
$APPCONF_DIR = realpath("{$APP_DIR}/appConf/");
$CONF_DIR = realpath("{$APP_DIR}/config/");
$baseConfig = require $APPCONF_DIR . '/base_config.php';
$APP_DIR = _dir(dirname(SRC_DIR), 'app');
$APPCONF_DIR = realpath(_dir($APP_DIR, 'appConf'));
$CONF_DIR = realpath(_dir($APP_DIR, 'config'));
$baseConfig = require _dir($APPCONF_DIR, 'base_config.php');
$config = loadToml($CONF_DIR);
$config = loadConfig($CONF_DIR);
$overrideFile = $CONF_DIR . '/admin-override.toml';
$overrideFile = _dir($CONF_DIR, 'admin-override.toml');
$overrideConfig = file_exists($overrideFile)
? loadTomlFile($overrideFile)
: [];
@ -168,7 +172,7 @@ abstract class BaseCommand extends Command {
// Create Request/Response Objects
$container->set('request', fn () => ServerRequestFactory::fromGlobals(
$_SERVER,
$GLOBALS['_SERVER'],
$_GET,
$_POST,
$_COOKIE,

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -29,7 +29,7 @@ class ClearThumbnails extends BaseCommand {
private function clearThumbs(): void
{
$imgDir = realpath(__DIR__ . '/../../public/images');
$imgDir = dirname(__DIR__, 3) . '/public/images';
$paths = [
'anime/*.jpg',

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -25,7 +25,8 @@ use Aviat\AnimeClient\API\{
use Aviat\AnimeClient\API;
use Aviat\AnimeClient\API\Anilist;
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
use Aviat\AnimeClient\Enum\{ListType, SyncAction};
use Aviat\AnimeClient\Enum;
use Aviat\AnimeClient\Enum\{MediaType, SyncAction};
use Aviat\AnimeClient\Types\FormItem;
use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException;
@ -73,7 +74,7 @@ final class SyncLists extends BaseCommand {
{
$this->init();
foreach ([ListType::ANIME, ListType::MANGA] as $type)
foreach ([MediaType::ANIME, MediaType::MANGA] as $type)
{
// Main Sync flow
$this->fetchCount($type);
@ -100,7 +101,7 @@ final class SyncLists extends BaseCommand {
$this->setCache($this->container->get('cache'));
$config = $this->container->get('config');
$anilistEnabled = $config->get([API::ANILIST, 'enabled']);
$anilistEnabled = $config->get([Enum\API::ANILIST, 'enabled']);
// We can't sync kitsu against itself!
if ( ! $anilistEnabled)
@ -165,8 +166,8 @@ final class SyncLists extends BaseCommand {
$this->clearLine();
return [
API::ANILIST => $anilist,
API::KITSU => $kitsu,
Enum\API::ANILIST => $anilist,
Enum\API::KITSU => $kitsu,
];
}
@ -182,17 +183,17 @@ final class SyncLists extends BaseCommand {
$this->echo('Normalizing List Data');
$progress = new Widgets\ProgressBar($this->getConsole(), 2, 50, FALSE);
$kitsu = $this->transformKitsu($type, $data[API::KITSU]);
$kitsu = $this->transformKitsu($type, $data[Enum\API::KITSU]);
$progress->incr();
$anilist = $this->transformAnilist($type, $data[API::ANILIST]);
$anilist = $this->transformAnilist($type, $data[Enum\API::ANILIST]);
$progress->incr();
$this->clearLine();
return [
API::ANILIST => $anilist,
API::KITSU => $kitsu,
Enum\API::ANILIST => $anilist,
Enum\API::KITSU => $kitsu,
];
}
@ -207,7 +208,7 @@ final class SyncLists extends BaseCommand {
{
$this->echo('Comparing List Items');
return $this->compareLists($type, $data[API::ANILIST], $data[API::KITSU]);
return $this->compareLists($type, $data[Enum\API::ANILIST], $data[Enum\API::KITSU]);
}
/**
@ -280,8 +281,8 @@ final class SyncLists extends BaseCommand {
private function fetchAnilist(string $type): array
{
static $list = [
ListType::ANIME => NULL,
ListType::MANGA => NULL,
MediaType::ANIME => NULL,
MediaType::MANGA => NULL,
];
// This uses a static so I don't have to fetch this list twice for a count
@ -435,12 +436,12 @@ final class SyncLists extends BaseCommand {
continue;
}
if (in_array(API::KITSU, $item['updateType'], TRUE))
if (in_array(Enum\API::KITSU, $item['updateType'], TRUE))
{
$kitsuUpdateItems[] = $item['data'];
}
if (in_array(API::ANILIST, $item['updateType'], TRUE))
if (in_array(Enum\API::ANILIST, $item['updateType'], TRUE))
{
$anilistUpdateItems[] = $item['data'];
}
@ -448,7 +449,7 @@ final class SyncLists extends BaseCommand {
continue;
}
$statusMap = ($type === ListType::ANIME) ? AnimeWatchingStatus::class : MangaReadingStatus::class;
$statusMap = ($type === MediaType::ANIME) ? AnimeWatchingStatus::class : MangaReadingStatus::class;
// Looks like this item only exists on Kitsu
$kItem = $kitsuItem['data'];
@ -528,7 +529,7 @@ final class SyncLists extends BaseCommand {
if ($kitsuItem['data']['status'] === 'completed' && $kitsuItem['data']['reconsuming'] === TRUE)
{
$update['data']['reconsuming'] = FALSE;
$return['updateType'][] = API::KITSU;
$return['updateType'][] = Enum\API::KITSU;
}
// If status is the same, and progress count is different, use greater progress
@ -537,12 +538,12 @@ final class SyncLists extends BaseCommand {
if ($diff['progress'] === self::KITSU_GREATER)
{
$update['data']['progress'] = $kitsuItem['data']['progress'];
$return['updateType'][] = API::ANILIST;
$return['updateType'][] = Enum\API::ANILIST;
}
else if($diff['progress'] === self::ANILIST_GREATER)
{
$update['data']['progress'] = $anilistItem['data']['progress'];
$return['updateType'][] = API::KITSU;
$return['updateType'][] = Enum\API::KITSU;
}
}
@ -552,12 +553,12 @@ final class SyncLists extends BaseCommand {
if ($dateDiff === self::KITSU_GREATER)
{
$update['data']['status'] = $kitsuItem['data']['status'];
$return['updateType'][] = API::ANILIST;
$return['updateType'][] = Enum\API::ANILIST;
}
else if ($dateDiff === self::ANILIST_GREATER)
{
$update['data']['status'] = $anilistItem['data']['status'];
$return['updateType'][] = API::KITSU;
$return['updateType'][] = Enum\API::KITSU;
}
}
@ -574,7 +575,7 @@ final class SyncLists extends BaseCommand {
$update['data']['progress'] = $kitsuItem['data']['progress'];
}
$return['updateType'][] = API::ANILIST;
$return['updateType'][] = Enum\API::ANILIST;
}
else if($dateDiff === self::ANILIST_GREATER)
{
@ -585,7 +586,7 @@ final class SyncLists extends BaseCommand {
$update['data']['progress'] = $kitsuItem['data']['progress'];
}
$return['updateType'][] = API::KITSU;
$return['updateType'][] = Enum\API::KITSU;
}
}
@ -599,12 +600,12 @@ final class SyncLists extends BaseCommand {
)
{
$update['data']['ratingTwenty'] = $kitsuItem['data']['ratingTwenty'];
$return['updateType'][] = API::ANILIST;
$return['updateType'][] = Enum\API::ANILIST;
}
else if($dateDiff === self::ANILIST_GREATER && $anilistItem['data']['rating'] !== 0)
{
$update['data']['ratingTwenty'] = $anilistItem['data']['rating'] * 2;
$return['updateType'][] = API::KITSU;
$return['updateType'][] = Enum\API::KITSU;
}
}
@ -614,12 +615,12 @@ final class SyncLists extends BaseCommand {
if ( ! empty($kitsuItem['data']['notes']))
{
$update['data']['notes'] = $kitsuItem['data']['notes'];
$return['updateType'][] = API::ANILIST;
$return['updateType'][] = Enum\API::ANILIST;
}
else
{
$update['data']['notes'] = $anilistItem['data']['notes'];
$return['updateType'][] = API::KITSU;
$return['updateType'][] = Enum\API::KITSU;
}
}
@ -629,12 +630,12 @@ final class SyncLists extends BaseCommand {
if ($diff['reconsumeCount'] === self::KITSU_GREATER)
{
$update['data']['reconsumeCount'] = $kitsuItem['data']['reconsumeCount'];
$return['updateType'][] = API::ANILIST;
$return['updateType'][] = Enum\API::ANILIST;
}
else if ($diff['reconsumeCount'] === self::ANILIST_GREATER)
{
$update['data']['reconsumeCount'] = $anilistItem['data']['reconsumeCount'];
$return['updateType'][] = API::KITSU;
$return['updateType'][] = Enum\API::KITSU;
}
}
@ -645,8 +646,8 @@ final class SyncLists extends BaseCommand {
}
$return['meta'] = [
API::KITSU => $kitsuItem['data'],
API::ANILIST => $anilistItem['data'],
Enum\API::KITSU => $kitsuItem['data'],
Enum\API::ANILIST => $anilistItem['data'],
'dateDiff' => $dateDiff,
'diff' => $diff,
];
@ -656,7 +657,7 @@ final class SyncLists extends BaseCommand {
// Fill in missing data values for update
// so I don't have to create a really complex graphql query
// to handle each combination of fields
if ($return['updateType'][0] === API::ANILIST)
if ($return['updateType'][0] === Enum\API::ANILIST)
{
// Anilist GraphQL expects a rating from 1-100
$prevData = [
@ -673,7 +674,7 @@ final class SyncLists extends BaseCommand {
$return['data']['data'] = array_merge($prevData, $return['data']['data']);
}
else if ($return['updateType'][0] === API::KITSU)
else if ($return['updateType'][0] === Enum\API::KITSU)
{
$prevData = [
'notes' => $anilistItem['data']['notes'],
@ -707,7 +708,7 @@ final class SyncLists extends BaseCommand {
* @param string $type
* @throws Throwable
*/
private function updateKitsuListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = ListType::ANIME): void
private function updateKitsuListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = MediaType::ANIME): void
{
$requester = new ParallelAPIRequest();
foreach($itemsToUpdate as $item)
@ -776,7 +777,7 @@ final class SyncLists extends BaseCommand {
* @param string $type
* @throws Throwable
*/
private function updateAnilistListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = ListType::ANIME): void
private function updateAnilistListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = MediaType::ANIME): void
{
$requester = new ParallelAPIRequest();

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -69,11 +69,11 @@ final class UpdateThumbnails extends ClearThumbnails {
public function getImageList(): array
{
$animeIds = array_map(
fn ($item) => $item['media']['id'],
static fn ($item) => $item['media']['id'],
$this->kitsuModel->getThumbList('ANIME')
);
$mangaIds = array_map(
fn ($item) => $item['media']['id'],
static fn ($item) => $item['media']['id'],
$this->kitsuModel->getThumbList('MANGA')
);

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -26,6 +26,7 @@ final class VerticalTabs {
* also used to generate id attributes
* @param array $tabData The data used to create the tab content, indexed by the tab label
* @param callable $cb The function to generate the tab content
* @param string $className
* @return string
*/
public function __invoke(

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -46,49 +46,41 @@ class Controller {
/**
* The authentication object
* @var Auth $auth ;
*/
protected Auth $auth;
/**
* Cache manager
* @var CacheInterface
*/
protected CacheInterface $cache;
/**
* The global configuration object
* @var ConfigInterface $config
*/
public ConfigInterface $config;
/**
* Request object
* @var ServerRequestInterface $request
*/
protected ServerRequestInterface $request;
/**
* Url generation class
* @var UrlGenerator
*/
protected UrlGenerator $urlGenerator;
/**
* Aura url generator
* @var Generator
*/
protected Generator $url;
/**
* Session segment
* @var Segment
*/
protected Segment $session;
/**
* Common data to be sent to views
* @var array
*/
protected array $baseData = [];

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -66,17 +66,17 @@ final class Anime extends BaseController {
/**
* Show a portion, or all of the anime list
*
* @param string|int $type - The section of the list
* @param string $view - List or cover view
* @param string|int $status - The section of the list
* @param string|null $view - List or cover view
* @throws ContainerException
* @throws NotFoundException
* @throws InvalidArgumentException
* @throws Throwable
* @return void
*/
public function index($type = KitsuWatchingStatus::WATCHING, string $view = NULL): void
public function index($status = KitsuWatchingStatus::WATCHING, ?string $view = NULL): void
{
if ( ! in_array($type, [
if ( ! in_array($status, [
'all',
'watching',
'plan_to_watch',
@ -88,10 +88,10 @@ final class Anime extends BaseController {
$this->errorPage(404, 'Not Found', 'Page not found');
}
$title = array_key_exists($type, AnimeWatchingStatus::ROUTE_TO_TITLE)
$title = array_key_exists($status, AnimeWatchingStatus::ROUTE_TO_TITLE)
? $this->formatTitle(
$this->config->get('whose_list') . "'s Anime List",
AnimeWatchingStatus::ROUTE_TO_TITLE[$type]
AnimeWatchingStatus::ROUTE_TO_TITLE[$status]
)
: '';
@ -100,8 +100,8 @@ final class Anime extends BaseController {
'list' => 'list'
];
$data = ($type !== 'all')
? $this->model->getList(AnimeWatchingStatus::ROUTE_TO_KITSU[$type])
$data = ($status !== 'all')
? $this->model->getList(AnimeWatchingStatus::ROUTE_TO_KITSU[$status])
: $this->model->getAllLists();
$this->outputHTML('anime/' . $viewMap[$view], [
@ -138,8 +138,6 @@ final class Anime extends BaseController {
/**
* Add an anime to the list
*
* @throws ContainerException
* @throws NotFoundException
* @throws Throwable
* @return void
*/
@ -215,8 +213,6 @@ final class Anime extends BaseController {
/**
* Update an anime item via a form submission
*
* @throws ContainerException
* @throws NotFoundException
* @throws Throwable
* @return void
*/
@ -305,17 +301,17 @@ final class Anime extends BaseController {
/**
* View details of an anime
*
* @param string $animeId
* @param string $id
* @throws ContainerException
* @throws NotFoundException
* @throws InvalidArgumentException
* @return void
*/
public function details(string $animeId): void
public function details(string $id): void
{
try
{
$data = $this->model->getAnime($animeId);
$data = $this->model->getAnime($id);
if ($data->isEmpty())
{
@ -338,7 +334,45 @@ final class Anime extends BaseController {
'data' => $data,
]);
}
catch (TypeError $e)
catch (TypeError)
{
$this->notFound(
$this->config->get('whose_list') .
"'s Anime List &middot; Anime &middot; " .
'Anime not found',
'Anime Not Found'
);
}
}
public function random(): void
{
try
{
$data = $this->model->getRandomAnime();
if ($data->isEmpty())
{
$this->notFound(
$this->config->get('whose_list') .
"'s Anime List &middot; Anime &middot; " .
'Anime not found',
'Anime Not Found'
);
return;
}
$this->outputHTML('anime/details', [
'title' => $this->formatTitle(
$this->config->get('whose_list') . "'s Anime List",
'Anime',
$data->title
),
'data' => $data,
]);
}
catch (TypeError)
{
$this->notFound(
$this->config->get('whose_list') .

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -88,13 +88,13 @@ final class AnimeCollection extends BaseController {
/**
* Show the anime collection page
*
* @param string $view
* @param string|null $view
* @throws ContainerException
* @throws NotFoundException
* @throws InvalidArgumentException
* @return void
*/
public function view($view): void
public function view(?string $view = ''): void
{
$viewMap = [
'' => 'cover',

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -303,19 +303,16 @@ final class Manga extends Controller {
/**
* View details of an manga
*
* @param string $manga_id
* @param string $id
* @throws ContainerException
* @throws NotFoundException
* @throws InvalidArgumentException
* @throws Throwable
* @return void
*/
public function details($manga_id): void
public function details(string $id): void
{
$data = $this->model->getManga($manga_id);
$staff = [];
$characters = [];
$data = $this->model->getManga($id);
if ($data->isEmpty())
{
$this->notFound(
@ -333,9 +330,40 @@ final class Manga extends Controller {
'Manga',
$data['title']
),
'characters' => $characters,
'data' => $data,
'staff' => $staff,
]);
}
/**
* View details of a random manga
*
* @throws ContainerException
* @throws NotFoundException
* @throws InvalidArgumentException
* @throws Throwable
* @return void
*/
public function random(): void
{
$data = $this->model->getRandomManga();
if ($data->isEmpty())
{
$this->notFound(
$this->config->get('whose_list') .
"'s Manga List &middot; Manga &middot; " .
'Manga not found',
'Manga Not Found'
);
return;
}
$this->outputHTML('manga/details', [
'title' => $this->formatTitle(
$this->config->get('whose_list') . "'s Manga List",
'Manga',
$data['title']
),
'data' => $data,
]);
}
}

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -268,7 +268,7 @@ final class Dispatcher extends RoutingBase {
* @param array $params
* @return void
*/
protected function call($controllerName, $method, array $params): void
protected function call(string $controllerName, string $method, array $params): void
{
$logger = $this->container->getLogger('default');
@ -282,7 +282,7 @@ final class Dispatcher extends RoutingBase {
$logger->debug('Dispatcher - controller arguments', $params);
}
call_user_func_array([$controller, $method], $params);
call_user_func_array([$controller, $method], array_values($params));
}
catch (FailedResponseException $e)
{
@ -388,21 +388,21 @@ final class Dispatcher extends RoutingBase {
$route['controller'] = $controllerClass;
// Select the appropriate router method based on the http verb
$add = array_key_exists('verb', $route)
$verb = array_key_exists('verb', $route)
? strtolower($route['verb'])
: 'get';
// Add the route to the router object
if ( ! array_key_exists('tokens', $route))
{
$routes[] = $this->router->$add($name, $path)->defaults($route);
$routes[] = $this->router->$verb($name, $path)->defaults($route);
continue;
}
$tokens = $route['tokens'];
unset($route['tokens']);
$routes[] = $this->router->$add($name, $path)
$routes[] = $this->router->$verb($name, $path)
->defaults($route)
->tokens($tokens);
}

View File

@ -4,19 +4,21 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient;
namespace Aviat\AnimeClient\Enum;
class API {
use Aviat\Ion\Enum;
final class API extends Enum {
public const ANILIST = 'anilist';
public const KITSU = 'kitsu';
}

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -19,9 +19,9 @@ namespace Aviat\AnimeClient\Enum;
use Aviat\Ion\Enum as BaseEnum;
/**
* Types of lists
* Types of media
*/
final class ListType extends BaseEnum {
final class MediaType extends BaseEnum {
public const ANIME = 'anime';
public const DRAMA = 'drama';
public const MANGA = 'manga';

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -52,15 +52,7 @@ final class FormGenerator {
*/
public static function new(ContainerInterface $container): self
{
try
{
return new static($container);
}
catch (\Throwable $e)
{
dump($e);
die();
}
return new self($container);
}
/**
@ -74,7 +66,7 @@ final class FormGenerator {
{
$type = $form['type'];
$display = $form['display'] ?? TRUE;
$value = $form['value'] ?? '';
$value = $form['value'] ?? $form['default'] ?? '';
if ($display === FALSE)
{
@ -101,6 +93,7 @@ final class FormGenerator {
'1' => 'Yes',
'0' => 'No',
];
$params['strict'] = true;
unset($params['attribs']['id']);
break;

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -49,7 +49,8 @@ final class Picture {
];
/**
* Create the html for an html picture element
* Create the html for an html picture element.
* Uses .webp images with fallback
*
* @param string $uri
* @param string $fallbackExt

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -187,14 +187,14 @@ final class Kitsu {
$host = parse_url($url, \PHP_URL_HOST);
$links[] = [
'meta' => static::getServiceMetaData($host),
'meta' => self::getServiceMetaData($host),
'link' => $streamingLink['url'],
'subs' => $streamingLink['subs'],
'dubs' => $streamingLink['dubs']
];
}
usort($links, fn ($a, $b) => $a['meta']['name'] <=> $b['meta']['name']);
usort($links, static fn ($a, $b) => $a['meta']['name'] <=> $b['meta']['name']);
return $links;
}
@ -282,7 +282,7 @@ final class Kitsu {
*/
protected static function getServiceMetaData(string $hostname = NULL): array
{
$hostname = str_replace('www.', '', $hostname);
$hostname = str_replace('www.', '', $hostname ?? '');
$serviceMap = [
'animelab.com' => [
@ -416,7 +416,7 @@ final class Kitsu {
* @param array $existingTitles
* @return bool
*/
private static function titleIsUnique(string $title = NULL, array $existingTitles = []): bool
private static function titleIsUnique(string $title = '', array $existingTitles = []): bool
{
if (empty($title))
{

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -49,15 +49,7 @@ final class MenuGenerator extends UrlGenerator {
*/
public static function new(ContainerInterface $container): self
{
try
{
return new static($container);
}
catch (\Throwable $e)
{
dump($e);
die();
}
return new self($container);
}
/**
@ -67,7 +59,7 @@ final class MenuGenerator extends UrlGenerator {
* @throws ConfigException
* @return string
*/
public function generate($menu) : string
public function generate(string $menu) : string
{
$menus = $this->config->get('menus');
$parsedConfig = $this->parseConfig($menus);

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -83,6 +83,16 @@ class Anime extends API {
return $this->kitsuModel->getAnime($slug);
}
/**
* Get information about a random anime
*
* @return AnimeType
*/
public function getRandomAnime(): AnimeType
{
return $this->kitsuModel->getRandomAnime();
}
/**
* Get anime by its kitsu id
*

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
@ -134,6 +134,7 @@ final class AnimeCollection extends Collection {
}
// Organize the media types into groups
// @TODO: make this more database-driven, rather than hardcoded
return [
'Common' => [
2 => $flatList[2], // Blu-ray

View File

@ -4,13 +4,13 @@
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
* PHP version 7.4+
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.1
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

Some files were not shown because too many files have changed in this diff Show More