develop #37

Merged
timw4mail merged 15 commits from develop into master 1 year ago
  1. 7
      .travis.yml
  2. 6
      Jenkinsfile
  3. 4
      RoboFile.php
  4. 4
      app/appConf/base_config.php
  5. 26
      app/appConf/routes.php
  6. 42
      app/bootstrap.php
  7. 2
      app/templates/anime-cover.php
  8. 6
      app/views/main-menu.php
  9. 6
      build/header_comment.txt
  10. 55
      build/phpunit.xml
  11. 21
      composer.json
  12. 2
      console
  13. 2
      frontEndSrc/test/ajax.php
  14. 8
      index.php
  15. 45
      phpunit.xml
  16. 17
      src/AnimeClient/API/APIRequestBuilder.php
  17. 6
      src/AnimeClient/API/AbstractListItem.php
  18. 6
      src/AnimeClient/API/Anilist/ListItem.php
  19. 6
      src/AnimeClient/API/Anilist/MissingIdException.php
  20. 8
      src/AnimeClient/API/Anilist/Model.php
  21. 8
      src/AnimeClient/API/Anilist/RequestBuilder.php
  22. 9
      src/AnimeClient/API/Anilist/RequestBuilderTrait.php
  23. 6
      src/AnimeClient/API/Anilist/Transformer/AnimeListTransformer.php
  24. 6
      src/AnimeClient/API/Anilist/Transformer/MangaListTransformer.php
  25. 24
      src/AnimeClient/API/Anilist/Types/MediaListEntry.php
  26. 6
      src/AnimeClient/API/CacheTrait.php
  27. 6
      src/AnimeClient/API/Enum/AnimeWatchingStatus/Anilist.php
  28. 6
      src/AnimeClient/API/Enum/AnimeWatchingStatus/Kitsu.php
  29. 6
      src/AnimeClient/API/Enum/AnimeWatchingStatus/Route.php
  30. 6
      src/AnimeClient/API/Enum/AnimeWatchingStatus/Title.php
  31. 6
      src/AnimeClient/API/Enum/MangaReadingStatus/Anilist.php
  32. 6
      src/AnimeClient/API/Enum/MangaReadingStatus/Kitsu.php
  33. 6
      src/AnimeClient/API/Enum/MangaReadingStatus/Route.php
  34. 6
      src/AnimeClient/API/Enum/MangaReadingStatus/Title.php
  35. 6
      src/AnimeClient/API/FailedResponseException.php
  36. 6
      src/AnimeClient/API/Kitsu/Auth.php
  37. 6
      src/AnimeClient/API/Kitsu/Enum/AnimeAiringStatus.php
  38. 6
      src/AnimeClient/API/Kitsu/Enum/MangaPublishingStatus.php
  39. 6
      src/AnimeClient/API/Kitsu/ListItem.php
  40. 40
      src/AnimeClient/API/Kitsu/Model.php
  41. 6
      src/AnimeClient/API/Kitsu/MutationTrait.php
  42. 134
      src/AnimeClient/API/Kitsu/Queries/RandomMedia.graphql
  43. 6
      src/AnimeClient/API/Kitsu/RequestBuilder.php
  44. 6
      src/AnimeClient/API/Kitsu/RequestBuilderTrait.php
  45. 6
      src/AnimeClient/API/Kitsu/Transformer/AnimeHistoryTransformer.php
  46. 6
      src/AnimeClient/API/Kitsu/Transformer/AnimeListTransformer.php
  47. 10
      src/AnimeClient/API/Kitsu/Transformer/AnimeTransformer.php
  48. 6
      src/AnimeClient/API/Kitsu/Transformer/CharacterTransformer.php
  49. 6
      src/AnimeClient/API/Kitsu/Transformer/HistoryTransformer.php
  50. 6
      src/AnimeClient/API/Kitsu/Transformer/LibraryEntryTransformer.php
  51. 6
      src/AnimeClient/API/Kitsu/Transformer/MangaHistoryTransformer.php
  52. 6
      src/AnimeClient/API/Kitsu/Transformer/MangaListTransformer.php
  53. 11
      src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php
  54. 6
      src/AnimeClient/API/Kitsu/Transformer/PersonTransformer.php
  55. 6
      src/AnimeClient/API/Kitsu/Transformer/UserTransformer.php
  56. 101
      src/AnimeClient/API/Kitsu/schema.graphql
  57. 6
      src/AnimeClient/API/Mapping/AnimeWatchingStatus.php
  58. 6
      src/AnimeClient/API/Mapping/MangaReadingStatus.php
  59. 6
      src/AnimeClient/API/ParallelAPIRequest.php
  60. 32
      src/AnimeClient/Anilist.php
  61. 95
      src/AnimeClient/AnimeClient.php
  62. 26
      src/AnimeClient/Command/BaseCommand.php
  63. 6
      src/AnimeClient/Command/CacheClear.php
  64. 6
      src/AnimeClient/Command/CachePrime.php
  65. 8
      src/AnimeClient/Command/ClearThumbnails.php
  66. 75
      src/AnimeClient/Command/SyncLists.php
  67. 10
      src/AnimeClient/Command/UpdateThumbnails.php
  68. 6
      src/AnimeClient/Component/AnimeCover.php
  69. 6
      src/AnimeClient/Component/Character.php
  70. 6
      src/AnimeClient/Component/ComponentTrait.php
  71. 6
      src/AnimeClient/Component/MangaCover.php
  72. 6
      src/AnimeClient/Component/Media.php
  73. 6
      src/AnimeClient/Component/Tabs.php
  74. 7
      src/AnimeClient/Component/VerticalTabs.php
  75. 14
      src/AnimeClient/Controller.php
  76. 72
      src/AnimeClient/Controller/Anime.php
  77. 10
      src/AnimeClient/Controller/AnimeCollection.php
  78. 6
      src/AnimeClient/Controller/Character.php
  79. 6
      src/AnimeClient/Controller/History.php
  80. 6
      src/AnimeClient/Controller/Images.php
  81. 50
      src/AnimeClient/Controller/Manga.php
  82. 6
      src/AnimeClient/Controller/Misc.php
  83. 6
      src/AnimeClient/Controller/People.php
  84. 6
      src/AnimeClient/Controller/Settings.php
  85. 6
      src/AnimeClient/Controller/User.php
  86. 16
      src/AnimeClient/Dispatcher.php
  87. 12
      src/AnimeClient/Enum/API.php
  88. 6
      src/AnimeClient/Enum/EventType.php
  89. 10
      src/AnimeClient/Enum/MediaType.php
  90. 6
      src/AnimeClient/Enum/SyncAction.php
  91. 19
      src/AnimeClient/FormGenerator.php
  92. 6
      src/AnimeClient/Helper/Form.php
  93. 6
      src/AnimeClient/Helper/Menu.php
  94. 9
      src/AnimeClient/Helper/Picture.php
  95. 14
      src/AnimeClient/Kitsu.php
  96. 18
      src/AnimeClient/MenuGenerator.php
  97. 6
      src/AnimeClient/Model/API.php
  98. 16
      src/AnimeClient/Model/Anime.php
  99. 7
      src/AnimeClient/Model/AnimeCollection.php
  100. 6
      src/AnimeClient/Model/Collection.php
  101. Some files were not shown because too many files have changed in this diff Show More

7
.travis.yml

@ -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

@ -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'
}
}

4
RoboFile.php

@ -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',

4
app/appConf/base_config.php

@ -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",

26
app/appConf/routes.php

@ -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',

42
app/bootstrap.php

@ -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;
};

2
app/templates/anime-cover.php

@ -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]): ?>

6
app/views/main-menu.php

@ -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' ?>

6
build/header_comment.txt

@ -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
*/

55
build/phpunit.xml

@ -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>
<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>

21
composer.json

@ -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",

2
console

@ -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');

2
frontEndSrc/test/ajax.php

@ -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))

8
index.php

@ -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)

45
phpunit.xml

@ -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>
<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>

17
src/AnimeClient/API/APIRequestBuilder.php

@ -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.');

6
src/AnimeClient/API/AbstractListItem.php

@ -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
*/

6
src/AnimeClient/API/Anilist/ListItem.php

@ -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
*/

6
src/AnimeClient/API/Anilist/MissingIdException.php

@ -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
*/

8
src/AnimeClient/API/Anilist/Model.php

@ -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;

8
src/AnimeClient/API/Anilist/RequestBuilder.php

@ -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;

9
src/AnimeClient/API/Anilist/RequestBuilderTrait.php

@ -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;

6
src/AnimeClient/API/Anilist/Transformer/AnimeListTransformer.php

@ -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
*/

6
src/AnimeClient/API/Anilist/Transformer/MangaListTransformer.php

@ -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
src/AnimeClient/API/Anilist/Types/MediaListEntry.php

@ -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;
}

6
src/AnimeClient/API/CacheTrait.php

@ -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
*/

6
src/AnimeClient/API/Enum/AnimeWatchingStatus/Anilist.php

@ -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
*/

6
src/AnimeClient/API/Enum/AnimeWatchingStatus/Kitsu.php

@ -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
*/

6
src/AnimeClient/API/Enum/AnimeWatchingStatus/Route.php

@ -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
*/

6
src/AnimeClient/API/Enum/AnimeWatchingStatus/Title.php

@ -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
*/

6
src/AnimeClient/API/Enum/MangaReadingStatus/Anilist.php

@ -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
*/

6
src/AnimeClient/API/Enum/MangaReadingStatus/Kitsu.php

@ -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
*/

6
src/AnimeClient/API/Enum/MangaReadingStatus/Route.php

@ -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
*/

6
src/AnimeClient/API/Enum/MangaReadingStatus/Title.php

@ -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
*/

6
src/AnimeClient/API/FailedResponseException.php

@ -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
*/

6
src/AnimeClient/API/Kitsu/Auth.php

@ -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
*/

6
src/AnimeClient/API/Kitsu/Enum/AnimeAiringStatus.php

@ -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
*/

6
src/AnimeClient/API/Kitsu/Enum/MangaPublishingStatus.php

@ -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
*/

6
src/AnimeClient/API/Kitsu/ListItem.php

@ -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
*/

40
src/AnimeClient/API/Kitsu/Model.php

@ -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);
}
/**

6
src/AnimeClient/API/Kitsu/MutationTrait.php

@ -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
src/AnimeClient/API/Kitsu/Queries/RandomMedia.graphql

@ -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