Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
223 changed files with 1297 additions and 902 deletions
Showing only changes of commit fe284d755b - Show all commits

View File

@ -4,7 +4,6 @@ install:
- composer install --ignore-platform-reqs - composer install --ignore-platform-reqs
php: php:
- 7.3
- 7.4 - 7.4
- nightly - nightly
@ -12,13 +11,6 @@ script:
- mkdir -p build/logs - mkdir -p build/logs
- php vendor/bin/phpunit -c build - php vendor/bin/phpunit -c build
#after_script:
# - CODECLIMATE_REPO_TOKEN=2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 vendor/bin/test-reporter
matrix: matrix:
allow_failures: allow_failures:
- php: nightly - php: nightly
#addons:
# code_climate:
# repo_token: 2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058

View File

@ -1,8 +1,13 @@
# Changelog # Changelog
## Version 5
* Updated PHP requirement to 7.4
* Added anime history view
## Version 4.2 ## Version 4.2
* Updated dependencies * Updated dependencies
* Updated PHP requirement to 7.3 * Updated PHP requirement to 7.3
* Added option to automatically set dark mode based on the OS setting
## Version 4.1 ## Version 4.1
* Added optional dark theme * Added optional dark theme

12
Jenkinsfile vendored
View File

@ -10,18 +10,6 @@ pipeline {
sh 'php composer.phar install --ignore-platform-reqs' sh 'php composer.phar install --ignore-platform-reqs'
} }
} }
stage('PHP 7.3') {
agent {
docker {
image 'php:7.3-alpine'
args '-u root --privileged'
}
}
steps {
sh 'apk add --no-cache git'
sh 'php ./vendor/bin/phpunit --colors=never'
}
}
stage('PHP 7.4') { stage('PHP 7.4') {
agent { agent {
docker { docker {

View File

@ -1,8 +1,8 @@
# Hummingbird Anime Client # Hummingbird Anime Client
Update your anime/manga list on Kitsu.io and MyAnimeList.net Update your anime/manga list on Kitsu.io and Anilist
[![Build Status](https://travis-ci.org/timw4mail/HummingBirdAnimeClient.svg?branch=master)](https://travis-ci.org/timw4mail/HummingBirdAnimeClient) [![Build Status](https://travis-ci.com/timw4mail/HummingBirdAnimeClient.svg?branch=master)](https://travis-ci.com/github/timw4mail/HummingBirdAnimeClient)
[![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=timw4mail/HummingBirdAnimeClient/develop)](https://jenkins.timshomepage.net/job/timw4mail/HummingBirdAnimeClient/develop) [![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=timw4mail/HummingBirdAnimeClient/develop)](https://jenkins.timshomepage.net/job/timw4mail/HummingBirdAnimeClient/develop)
[[Hosted Example](https://list.timshomepage.net)] [[Hosted Example](https://list.timshomepage.net)]
@ -31,7 +31,7 @@ Update your anime/manga list on Kitsu.io and MyAnimeList.net
### Requirements ### Requirements
* PHP 7.3+ * PHP 7.4+
* PDO SQLite or PDO PostgreSQL (For collection tab) * PDO SQLite or PDO PostgreSQL (For collection tab)
* GD extension for caching images * GD extension for caching images

View File

@ -193,6 +193,16 @@ $routes = [
'username' => '.*?' 'username' => '.*?'
] ]
], ],
'anime_history' => [
'controller' => 'history',
'path' => '/history/anime',
'action' => 'anime',
],
'manga_history' => [
'controller' => 'history',
'path' => '/history/manga',
'action' => 'manga',
],
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Default / Shared routes // Default / Shared routes
// --------------------------------------------------------------------- // ---------------------------------------------------------------------

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -28,14 +28,15 @@ use Aviat\AnimeClient\Model;
use Aviat\Banker\Pool; use Aviat\Banker\Pool;
use Aviat\Ion\Config; use Aviat\Ion\Config;
use Aviat\Ion\Di\Container; use Aviat\Ion\Di\Container;
use Aviat\Ion\Di\ContainerInterface;
use Laminas\Diactoros\{Response, ServerRequestFactory};
use Monolog\Handler\RotatingFileHandler; use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger; use Monolog\Logger;
use Zend\Diactoros\{Response, ServerRequestFactory};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Setup DI container // Setup DI container
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
return static function ($configArray = []) { return static function (array $configArray = []): Container {
$container = new Container(); $container = new Container();
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -60,26 +61,20 @@ return static function ($configArray = []) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Create Config Object // Create Config Object
$container->set('config', static function() use ($configArray) { $container->set('config', fn () => new Config($configArray));
return new Config($configArray);
});
// Create Cache Object // Create Cache Object
$container->set('cache', static function($container): Pool { $container->set('cache', static function(ContainerInterface $container): Pool {
$logger = $container->getLogger(); $logger = $container->getLogger();
$config = $container->get('config')->get('cache'); $config = $container->get('config')->get('cache');
return new Pool($config, $logger); return new Pool($config, $logger);
}); });
// Create List Cache
// Create Aura Router Object // Create Aura Router Object
$container->set('aura-router', static function() { $container->set('aura-router', fn() => new RouterContainer);
return new RouterContainer;
});
// Create Html helper Object // Create Html helper Object
$container->set('html-helper', static function($container) { $container->set('html-helper', static function(ContainerInterface $container) {
$htmlHelper = (new HelperLocatorFactory)->newInstance(); $htmlHelper = (new HelperLocatorFactory)->newInstance();
$htmlHelper->set('menu', static function() use ($container) { $htmlHelper->set('menu', static function() use ($container) {
$menuHelper = new Helper\Menu(); $menuHelper = new Helper\Menu();
@ -101,31 +96,23 @@ return static function ($configArray = []) {
}); });
// Create Request/Response Objects // Create Request/Response Objects
$container->set('request', static function() { $container->set('request', fn () => ServerRequestFactory::fromGlobals(
return ServerRequestFactory::fromGlobals(
$_SERVER, $_SERVER,
$_GET, $_GET,
$_POST, $_POST,
$_COOKIE, $_COOKIE,
$_FILES $_FILES
); ));
}); $container->set('response', fn () => new Response);
$container->set('response', static function() {
return new Response;
});
// Create session Object // Create session Object
$container->set('session', static function() { $container->set('session', fn () => (new SessionFactory())->newInstance($_COOKIE));
return (new SessionFactory())->newInstance($_COOKIE);
});
// Miscellaneous helper methods // Miscellaneous helper methods
$container->set('util', static function($container): Util { $container->set('util', fn ($container) => new Util($container));
return new Util($container);
});
// Models // Models
$container->set('kitsu-model', static function($container): Kitsu\Model { $container->set('kitsu-model', static function(ContainerInterface $container): Kitsu\Model {
$requestBuilder = new KitsuRequestBuilder(); $requestBuilder = new KitsuRequestBuilder();
$requestBuilder->setLogger($container->getLogger('kitsu-request')); $requestBuilder->setLogger($container->getLogger('kitsu-request'));
@ -141,7 +128,7 @@ return static function ($configArray = []) {
$model->setCache($cache); $model->setCache($cache);
return $model; return $model;
}); });
$container->set('anilist-model', static function($container): Anilist\Model { $container->set('anilist-model', static function(ContainerInterface $container): Anilist\Model {
$requestBuilder = new Anilist\AnilistRequestBuilder(); $requestBuilder = new Anilist\AnilistRequestBuilder();
$requestBuilder->setLogger($container->getLogger('anilist-request')); $requestBuilder->setLogger($container->getLogger('anilist-request'));
@ -155,19 +142,10 @@ return static function ($configArray = []) {
return $model; return $model;
}); });
$container->set('anime-model', fn ($container) => new Model\Anime($container));
$container->set('anime-model', static function($container) { $container->set('manga-model', fn ($container) => new Model\Manga($container));
return new Model\Anime($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('manga-model', static function($container) {
return new Model\Manga($container);
});
$container->set('anime-collection-model', static function($container) {
return new Model\AnimeCollection($container);
});
$container->set('manga-collection-model', static function($container) {
return new Model\MangaCollection($container);
});
$container->set('settings-model', static function($container) { $container->set('settings-model', static function($container) {
$model = new Model\Settings($container->get('config')); $model = new Model\Settings($container->get('config'));
$model->setContainer($container); $model->setContainer($container);
@ -175,19 +153,13 @@ return static function ($configArray = []) {
}); });
// Miscellaneous Classes // Miscellaneous Classes
$container->set('auth', static function($container) { $container->set('auth', fn ($container) => new Kitsu\Auth($container));
return new Kitsu\Auth($container); $container->set('url-generator', fn ($container) => new UrlGenerator($container));
});
$container->set('url-generator', static function($container) {
return new UrlGenerator($container);
});
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Dispatcher // Dispatcher
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$container->set('dispatcher', static function($container) { $container->set('dispatcher', fn ($container) => new Dispatcher($container));
return new Dispatcher($container);
});
return $container; return $container;
}; };

View File

@ -75,20 +75,20 @@
<?php foreach($item['anime']['streaming_links'] as $link): ?> <?php foreach($item['anime']['streaming_links'] as $link): ?>
<?php if ($link['meta']['link'] !== FALSE): ?> <?php if ($link['meta']['link'] !== FALSE): ?>
<a href="<?= $link['link'] ?>" title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>"> <a href="<?= $link['link'] ?>" title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>">
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [ <?= $helper->img("/public/images/{$link['meta']['image']}", [
'class' => 'streaming-logo', 'class' => 'streaming-logo',
'width' => 50, 'width' => 50,
'height' => 50, 'height' => 50,
'alt' => "{$link['meta']['name']} logo", 'alt' => "{$link['meta']['name']} logo",
]); ?> ]) ?>
</a> </a>
<?php else: ?> <?php else: ?>
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [ <?= $helper->img("/public/images/{$link['meta']['image']}", [
'class' => 'streaming-logo', 'class' => 'streaming-logo',
'width' => 50, 'width' => 50,
'height' => 50, 'height' => 50,
'alt' => "{$link['meta']['name']} logo", 'alt' => "{$link['meta']['name']} logo",
]); ?> ]) ?>
<?php endif ?> <?php endif ?>
<?php endforeach ?> <?php endforeach ?>
</td> </td>

View File

@ -0,0 +1,19 @@
<main class="details fixed">
<?php if (empty($items)): ?>
<h3>No recent watch history.</h3>
<?php else: ?>
<section>
<?php foreach ($items as $name => $item): ?>
<article class="flex flex-no-wrap flex-justify-start">
<section class="flex-self-center history-img"><?= $helper->picture(
$item['coverImg'],
'jpg',
['width' => '110px', 'height' => '156px'],
['width' => '110px', 'height' => '156px']
) ?></section>
<section class="flex-self-center"><?= $item['action'] ?></section>
</article>
<?php endforeach ?>
</section>
<?php endif ?>
</main>

View File

@ -5,8 +5,8 @@ namespace Aviat\AnimeClient;
$whose = $config->get('whose_list') . "'s "; $whose = $config->get('whose_list') . "'s ";
$lastSegment = $urlGenerator->lastSegment(); $lastSegment = $urlGenerator->lastSegment();
$extraSegment = $lastSegment === 'list' ? '/list' : ''; $extraSegment = $lastSegment === 'list' ? '/list' : '';
$hasAnime = stripos($_SERVER['REQUEST_URI'], 'anime') !== FALSE; $hasAnime = stripos($_SERVER['REQUEST_URI'], 'anime') === 1;
$hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE; $hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') === 1;
?> ?>
<div id="main-nav" class="flex flex-align-end flex-wrap"> <div id="main-nav" class="flex flex-align-end flex-wrap">

View File

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

View File

@ -30,7 +30,7 @@
"config": { "config": {
"lock": false, "lock": false,
"platform": { "platform": {
"php": "7.3" "php": "7.4"
} }
}, },
"require": { "require": {
@ -39,7 +39,7 @@
"aura/router": "^3.0", "aura/router": "^3.0",
"aura/session": "^2.0", "aura/session": "^2.0",
"aviat/banker": "^2.0.0", "aviat/banker": "^2.0.0",
"aviat/query": "^2.5.1", "aviat/query": "dev-develop",
"danielstjules/stringy": "^3.1.0", "danielstjules/stringy": "^3.1.0",
"ext-dom": "*", "ext-dom": "*",
"ext-iconv": "*", "ext-iconv": "*",
@ -50,7 +50,7 @@
"laminas/laminas-httphandlerrunner": "^1.0", "laminas/laminas-httphandlerrunner": "^1.0",
"maximebf/consolekit": "^1.0", "maximebf/consolekit": "^1.0",
"monolog/monolog": "^2.0.1", "monolog/monolog": "^2.0.1",
"php": "^7.3", "php": ">=7.4",
"psr/container": "~1.0", "psr/container": "~1.0",
"psr/http-message": "~1.0", "psr/http-message": "~1.0",
"psr/log": "~1.0", "psr/log": "~1.0",
@ -60,14 +60,14 @@
"consolidation/robo": "^2.0.0", "consolidation/robo": "^2.0.0",
"filp/whoops": "^2.1", "filp/whoops": "^2.1",
"pdepend/pdepend": "^2.2", "pdepend/pdepend": "^2.2",
"phploc/phploc": "^5.0", "phploc/phploc": "^6.0.2",
"phpmd/phpmd": "^2.8", "phpmd/phpmd": "^2.8",
"phpstan/phpstan": "^0.12.0", "phpstan/phpstan": "^0.12.0",
"phpunit/phpunit": "^8.4.3", "phpunit/phpunit": "^9.1.1",
"roave/security-advisories": "dev-master", "roave/security-advisories": "dev-master",
"robmorgan/phinx": "^0.10.6", "robmorgan/phinx": "^0.10.6",
"sebastian/phpcpd": "^4.1.0", "sebastian/phpcpd": "^5.0.2",
"spatie/phpunit-snapshot-assertions": "^2.2.1", "spatie/phpunit-snapshot-assertions": "^4.1.0",
"squizlabs/php_codesniffer": "^3.2.2", "squizlabs/php_codesniffer": "^3.2.2",
"symfony/var-dumper": "^5", "symfony/var-dumper": "^5",
"theseer/phpdox": "*" "theseer/phpdox": "*"

View File

@ -888,6 +888,11 @@ aside picture, aside img {
filter: drop-shadow(0 -1px 4px #fff); filter: drop-shadow(0 -1px 4px #fff);
} }
.history-img {
width: 110px;
height: 156px;
}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
Settings Form Settings Form
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/

View File

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
const e=(t,n)=>{let o=(t.document||t.ownerDocument).querySelectorAll(n),r=e.length;for(;--r>=0&&o.item(r)!==t;);return r>-1},t={noop:()=>{},$(e,t=null){if("string"!=typeof e)return e;t=null!==t&&1===t.nodeType?t:document;let n=[];return e.match(/^#([\w]+$)/)?n.push(document.getElementById(e.split("#")[1])):n=[].slice.apply(t.querySelectorAll(e)),n},hasElement:e=>t.$(e).length>0,scrollToTop(){t.$("header")[0].scrollIntoView(!0)},hide(e){"string"==typeof e&&(e=t.$(e)),Array.isArray(e)?e.forEach(e=>e.setAttribute("hidden","hidden")):e.setAttribute("hidden","hidden")},show(e){"string"==typeof e&&(e=t.$(e)),Array.isArray(e)?e.forEach(e=>e.removeAttribute("hidden")):e.removeAttribute("hidden")},showMessage(e,n){let o=`<div class='message ${e}'>\n\t\t\t\t<span class='icon'></span>\n\t\t\t\t${n}\n\t\t\t\t<span class='close'></span>\n\t\t\t</div>`,r=t.$(".message");void 0!==r[0]&&r[0].remove(),t.$("header")[0].insertAdjacentHTML("beforeend",o)},closestParent(t,n){if(void 0!==Element.prototype.closest)return t.closest(n);for(;t!==document.documentElement;){if(e(t,n))return t;t=t.parentElement}return null},url(e){let t="//"+document.location.host;return t+="/"===e.charAt(0)?e:"/"+e,t},throttle(e,t,n){let o=!1;return function(...r){const a=n||this;o||(t.apply(a,r),o=!0,setTimeout((function(){o=!1}),e))}}};function n(e,t,o){t.match(/^([\w\-]+)$/)||t.split(" ").forEach(t=>{n(e,t,o)}),e.addEventListener(t,o,!1)}function o(e){let t=[];return Object.keys(e).forEach(n=>{let o=e[n].toString();n=encodeURIComponent(n),o=encodeURIComponent(o),t.push(`${n}=${o}`)}),t.join("&")}t.on=(e,o,r,a)=>{void 0===a?(a=r,t.$(e).forEach(e=>{n(e,o,a)})):t.$(e).forEach(e=>{!function(e,o,r,a){n(e,r,n=>{t.$(o,e).forEach(e=>{n.target==e&&(a.call(e,n),n.stopPropagation())})})}(e,r,o,a)})},t.ajax=(e,n)=>{const r={data:{},type:"GET",dataType:"",success:t.noop,mimeType:"application/x-www-form-urlencoded",error:t.noop};n={...r,...n};let a=new XMLHttpRequest,s=String(n.type).toUpperCase();"GET"===s&&(e+=e.match(/\?/)?o(n.data):"?"+o(n.data)),a.open(s,e),a.onreadystatechange=()=>{if(4===a.readyState){let e="";e="json"===a.responseType?JSON.parse(a.responseText):a.responseText,a.status>299?n.error.call(null,a.status,e,a.response):n.success.call(null,e,a.status)}},"json"===n.dataType?(n.data=JSON.stringify(n.data),n.mimeType="application/json"):n.data=o(n.data),a.setRequestHeader("Content-Type",n.mimeType),"GET"===s?a.send(null):a.send(n.data)},t.get=(e,n,o=null)=>(null===o&&(o=n,n={}),t.ajax(e,{data:n,success:o})),t.on("header","click",".message",(function(e){t.hide(e.target)})),t.on("form.js-delete","submit",(function(e){!1===confirm("Are you ABSOLUTELY SURE you want to delete this item?")&&(e.preventDefault(),e.stopPropagation())})),t.on(".js-clear-cache","click",(function(){t.get("/cache_purge",()=>{t.showMessage("success","Successfully purged api cache")})})),t.on(".vertical-tabs input","change",(function(e){const t=e.currentTarget.parentElement.getBoundingClientRect().top+window.pageYOffset;window.scrollTo({top:t,behavior:"smooth"})})),t.on(".media-filter","input",(function(e){const n=e.target.value,o=new RegExp(n,"i");""!==n?(t.$("article.media").forEach(e=>{const n=t.$(".name a",e)[0],r=String(n.textContent).trim();o.test(r)?t.show(e):t.hide(e)}),t.$("table.media-wrap tbody tr").forEach(e=>{const n=t.$("td.align-left",e)[0],r=t.$("a",n)[0],a=String(r.textContent).trim(),s=String(n.textContent).trim();o.test(a)||o.test(s)?t.show(e):t.hide(e)})):(t.show("article.media"),t.show("table.media-wrap tbody tr"))})),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(e=>{console.log("Service worker registered",e.scope)}).catch(e=>{console.error("Failed to register service worker",e)});

File diff suppressed because one or more lines are too long

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -38,37 +38,37 @@ abstract class APIRequestBuilder {
* Url prefix for making url requests * Url prefix for making url requests
* @var string * @var string
*/ */
protected $baseUrl = ''; protected string $baseUrl = '';
/** /**
* Url path of the request * Url path of the request
* @var string * @var string
*/ */
protected $path = ''; protected string $path = '';
/** /**
* Query string for the request * Query string for the request
* @var string * @var string
*/ */
protected $query = ''; protected string $query = '';
/** /**
* Default request headers * Default request headers
* @var array * @var array
*/ */
protected $defaultHeaders = []; protected array $defaultHeaders = [];
/** /**
* Valid HTTP request methods * Valid HTTP request methods
* @var array * @var array
*/ */
protected $validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']; protected array $validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];
/** /**
* The current request * The current request
* @var Request * @var Request
*/ */
protected $request; protected Request $request;
/** /**
* Do a basic minimal GET request * Do a basic minimal GET request
@ -78,8 +78,10 @@ abstract class APIRequestBuilder {
*/ */
public static function simpleRequest(string $uri): Request public static function simpleRequest(string $uri): Request
{ {
return (new Request($uri)) $request = (new Request($uri));
->setHeader('User-Agent', USER_AGENT); $request->setHeader('User-Agent', USER_AGENT);
return $request;
} }
/** /**

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -26,20 +26,20 @@ final class AnilistRequestBuilder extends APIRequestBuilder {
* The base url for api requests * The base url for api requests
* @var string $base_url * @var string $base_url
*/ */
protected $baseUrl = 'https://graphql.anilist.co'; protected string $baseUrl = 'https://graphql.anilist.co';
/** /**
* Valid HTTP request methods * Valid HTTP request methods
* @var array * @var array
*/ */
protected $validMethods = ['POST']; protected array $validMethods = ['POST'];
/** /**
* HTTP headers to send with every request * HTTP headers to send with every request
* *
* @var array * @var array
*/ */
protected $defaultHeaders = [ protected array $defaultHeaders = [
'User-Agent' => USER_AGENT, 'User-Agent' => USER_AGENT,
'Accept' => 'application/json', 'Accept' => 'application/json',
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -38,20 +38,20 @@ trait AnilistTrait {
* The request builder for the Anilist API * The request builder for the Anilist API
* @var AnilistRequestBuilder * @var AnilistRequestBuilder
*/ */
protected $requestBuilder; protected AnilistRequestBuilder $requestBuilder;
/** /**
* The base url for api requests * The base url for api requests
* @var string $base_url * @var string $base_url
*/ */
protected $baseUrl = Anilist::BASE_URL; protected string $baseUrl = Anilist::BASE_URL;
/** /**
* HTTP headers to send with every request * HTTP headers to send with every request
* *
* @var array * @var array
*/ */
protected $defaultHeaders = [ protected array $defaultHeaders = [
'Accept' => 'application/json', 'Accept' => 'application/json',
'Accept-Encoding' => 'gzip', 'Accept-Encoding' => 'gzip',
'Content-type' => 'application/json', 'Content-type' => 'application/json',

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -39,7 +39,7 @@ final class Model
/** /**
* @var ListItem * @var ListItem
*/ */
private $listItem; private ListItem $listItem;
/** /**
* Constructor * Constructor

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -26,7 +26,7 @@ trait CacheTrait {
/** /**
* @var Pool * @var Pool
*/ */
protected $cache; protected Pool $cache;
/** /**
* Inject the cache object * Inject the cache object

View File

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

View File

@ -4,18 +4,20 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
namespace Aviat\AnimeClient\API; namespace Aviat\AnimeClient\API;
use function in_array;
/** /**
* Class encapsulating Json API data structure for a request or response * Class encapsulating Json API data structure for a request or response
*/ */
@ -105,7 +107,7 @@ final class JsonAPI {
$relationship =& $item['relationships'][$relType]; $relationship =& $item['relationships'][$relType];
unset($relationship['data']); unset($relationship['data']);
if (\in_array($relType, $singular, TRUE)) if (in_array($relType, $singular, TRUE))
{ {
$relationship = $included[$dataType][$idKey]; $relationship = $included[$dataType][$idKey];
continue; continue;
@ -202,11 +204,11 @@ final class JsonAPI {
{ {
foreach($items as $id => $item) foreach($items as $id => $item)
{ {
if (array_key_exists('relationships', $item) && \is_array($item['relationships'])) if (array_key_exists('relationships', $item) && is_array($item['relationships']))
{ {
foreach($item['relationships'] as $relType => $props) foreach($item['relationships'] as $relType => $props)
{ {
if (array_key_exists('data', $props) && \is_array($props['data']) && array_key_exists('id', $props['data'])) if (array_key_exists('data', $props) && is_array($props['data']) && array_key_exists('id', $props['data']))
{ {
$idKey = $props['data']['id']; $idKey = $props['data']['id'];
$dataType = $props['data']['type']; $dataType = $props['data']['type'];
@ -340,7 +342,7 @@ final class JsonAPI {
foreach ($data['data'] as $item) foreach ($data['data'] as $item)
{ {
if (\is_array($item) && array_key_exists('id', $item)) if (is_array($item) && array_key_exists('id', $item))
{ {
$organized[$key][] = $item['id']; $organized[$key][] = $item['id'];
} }

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -164,9 +164,7 @@ final class Kitsu {
]; ];
} }
usort($links, function ($a, $b) { usort($links, fn ($a, $b) => $a['meta']['name'] <=> $b['meta']['name']);
return $a['meta']['name'] <=> $b['meta']['name'];
});
return $links; return $links;
} }

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -42,14 +42,14 @@ final class Auth {
* *
* @var Model * @var Model
*/ */
private $model; private Model $model;
/** /**
* Session object * Session object
* *
* @var Segment * @var Segment
*/ */
private $segment; private Segment $segment;
/** /**
* Constructor * Constructor
@ -91,9 +91,9 @@ final class Auth {
$cacheItem->save(); $cacheItem->save();
// Set the token expiration in the cache // Set the token expiration in the cache
$expire_time = $auth['created_at'] + $auth['expires_in']; $expireTime = $auth['created_at'] + $auth['expires_in'];
$cacheItem = $this->cache->getItem(K::AUTH_TOKEN_EXP_CACHE_KEY); $cacheItem = $this->cache->getItem(K::AUTH_TOKEN_EXP_CACHE_KEY);
$cacheItem->set($expire_time); $cacheItem->set($expireTime);
$cacheItem->save(); $cacheItem->save();
// Set the refresh token in the cache // Set the refresh token in the cache
@ -103,7 +103,7 @@ final class Auth {
// Set the session values // Set the session values
$this->segment->set('auth_token', $auth['access_token']); $this->segment->set('auth_token', $auth['access_token']);
$this->segment->set('auth_token_expires', $expire_time); $this->segment->set('auth_token_expires', $expireTime);
$this->segment->set('refresh_token', $auth['refresh_token']); $this->segment->set('refresh_token', $auth['refresh_token']);
return TRUE; return TRUE;

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -25,14 +25,14 @@ final class KitsuRequestBuilder extends APIRequestBuilder {
* The base url for api requests * The base url for api requests
* @var string $base_url * @var string $base_url
*/ */
protected $baseUrl = 'https://kitsu.io/api/edge/'; protected string $baseUrl = 'https://kitsu.io/api/edge/';
/** /**
* HTTP headers to send with every request * HTTP headers to send with every request
* *
* @var array * @var array
*/ */
protected $defaultHeaders = [ protected array $defaultHeaders = [
'User-Agent' => USER_AGENT, 'User-Agent' => USER_AGENT,
'Accept' => 'application/vnd.api+json', 'Accept' => 'application/vnd.api+json',
'Content-Type' => 'application/vnd.api+json', 'Content-Type' => 'application/vnd.api+json',

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -38,7 +38,7 @@ trait KitsuTrait {
* The request builder for the Kitsu API * The request builder for the Kitsu API
* @var KitsuRequestBuilder * @var KitsuRequestBuilder
*/ */
protected $requestBuilder; protected KitsuRequestBuilder $requestBuilder;
/** /**
* Set the request builder object * Set the request builder object
@ -176,7 +176,7 @@ trait KitsuTrait {
$logger->warning('Non 200 response for api call', (array)$response); $logger->warning('Non 200 response for api call', (array)$response);
} }
throw new FailedResponseException('Failed to get the proper response from the API'); // throw new FailedResponseException('Failed to get the proper response from the API');
} }
try try

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -31,6 +31,7 @@ use Aviat\AnimeClient\API\Enum\{
}; };
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus}; use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
use Aviat\AnimeClient\API\Kitsu\Transformer\{ use Aviat\AnimeClient\API\Kitsu\Transformer\{
AnimeHistoryTransformer,
AnimeTransformer, AnimeTransformer,
AnimeListTransformer, AnimeListTransformer,
MangaTransformer, MangaTransformer,
@ -65,27 +66,27 @@ final class Model {
* *
* @var AnimeListTransformer * @var AnimeListTransformer
*/ */
private $animeListTransformer; private AnimeListTransformer $animeListTransformer;
/** /**
* @var AnimeTransformer * @var AnimeTransformer
*/ */
private $animeTransformer; private AnimeTransformer $animeTransformer;
/** /**
* @var ListItem * @var ListItem
*/ */
private $listItem; private ListItem $listItem;
/** /**
* @var MangaTransformer * @var MangaTransformer
*/ */
private $mangaTransformer; private MangaTransformer $mangaTransformer;
/** /**
* @var MangaListTransformer * @var MangaListTransformer
*/ */
private $mangaListTransformer; private MangaListTransformer $mangaListTransformer;
/** /**
* Constructor * Constructor
@ -173,6 +174,38 @@ final class Model {
return FALSE; return FALSE;
} }
/**
* Retrieve the data for the anime watch history page
*
* @return array
* @throws InvalidArgumentException
* @throws Throwable
*/
public function getAnimeHistory(): array
{
$raw = $this->getRawHistoryList('anime');
$organized = JsonAPI::organizeData($raw);
$transformer = new AnimeHistoryTransformer();
$transformer->setContainer($this->getContainer());
return $transformer->transform($organized);
}
/**
* Retrieve the data for the manga read history page
*
* @return array
* @throws InvalidArgumentException
* @throws Throwable
*/
public function getMangaHistory(): array
{
$raw = $this->getRawHistoryList('manga');
return JsonAPI::organizeData($raw);
}
/** /**
* Get the userid for a username from Kitsu * Get the userid for a username from Kitsu
* *
@ -455,7 +488,7 @@ final class Model {
'query' => [ 'query' => [
'filter' => [ 'filter' => [
'user_id' => $this->getUserIdByUsername(), 'user_id' => $this->getUserIdByUsername(),
'media_type' => 'Anime' 'kind' => 'anime'
], ],
'page' => [ 'page' => [
'limit' => 1 'limit' => 1
@ -584,7 +617,7 @@ final class Model {
$defaultOptions = [ $defaultOptions = [
'filter' => [ 'filter' => [
'user_id' => $this->getUserIdByUsername($this->getUsername()), 'user_id' => $this->getUserIdByUsername($this->getUsername()),
'media_type' => 'Anime' 'kind' => 'anime'
], ],
'page' => [ 'page' => [
'offset' => $offset, 'offset' => $offset,
@ -610,7 +643,7 @@ final class Model {
$options = [ $options = [
'filter' => [ 'filter' => [
'user_id' => $this->getUserIdByUsername($this->getUsername()), 'user_id' => $this->getUserIdByUsername($this->getUsername()),
'media_type' => 'Anime', 'kind' => 'anime',
'status' => $status, 'status' => $status,
], ],
'include' => 'media,media.categories,media.mappings,anime.streamingLinks', 'include' => 'media,media.categories,media.mappings,anime.streamingLinks',
@ -669,7 +702,7 @@ final class Model {
'query' => [ 'query' => [
'filter' => [ 'filter' => [
'user_id' => $this->getUserIdByUsername($this->getUsername()), 'user_id' => $this->getUserIdByUsername($this->getUsername()),
'media_type' => 'Manga', 'kind' => 'manga',
'status' => $status, 'status' => $status,
], ],
'include' => 'media,media.categories,media.mappings', 'include' => 'media,media.categories,media.mappings',
@ -724,7 +757,7 @@ final class Model {
'query' => [ 'query' => [
'filter' => [ 'filter' => [
'user_id' => $this->getUserIdByUsername(), 'user_id' => $this->getUserIdByUsername(),
'media_type' => 'Manga' 'kind' => 'manga'
], ],
'page' => [ 'page' => [
'limit' => 1 'limit' => 1
@ -817,7 +850,7 @@ final class Model {
$defaultOptions = [ $defaultOptions = [
'filter' => [ 'filter' => [
'user_id' => $this->getUserIdByUsername($this->getUsername()), 'user_id' => $this->getUserIdByUsername($this->getUsername()),
'media_type' => 'Manga' 'kind' => 'manga'
], ],
'page' => [ 'page' => [
'offset' => $offset, 'offset' => $offset,
@ -942,6 +975,71 @@ final class Model {
return $this->listItem->delete($id); return $this->listItem->delete($id);
} }
/**
* Get the aggregated pages of anime or manga history
*
* @param string $type
* @param int $entries
* @return array
* @throws InvalidArgumentException
* @throws Throwable
*/
protected function getRawHistoryList(string $type = 'anime', int $entries = 60): array
{
$size = 20;
$pages = ceil($entries / $size);
$requester = new ParallelAPIRequest();
// Set up requests
for ($i = 0; $i < $pages; $i++)
{
$offset = $i * $size;
$requester->addRequest($this->getRawHistoryPage($type, $offset, $size));
}
$responses = $requester->makeRequests();
$output = [];
foreach($responses as $response)
{
$data = Json::decode($response);
$output[] = $data;
}
return array_merge_recursive(...$output);
}
/**
* Retrieve one page of the anime or manga history
*
* @param string $type
* @param int $offset
* @param int $limit
* @return Request
* @throws InvalidArgumentException
*/
protected function getRawHistoryPage(string $type, int $offset, int $limit = 20): Request
{
return $this->setUpRequest('GET', 'library-events', [
'query' => [
'filter' => [
'kind' => 'progressed,updated',
'userId' => $this->getUserIdByUsername($this->getUsername()),
],
'page' => [
'offset' => $offset,
'limit' => $limit,
],
'fields' => ($type === 'anime')
? ['anime' => 'canonicalTitle,titles,slug,posterImage']
: ['manga' => 'canonicalTitle,titles,slug,posterImage'],
'sort' => '-updated_at',
'include' => $type,
],
]);
}
/** /**
* Get the kitsu username from config * Get the kitsu username from config
* *

View File

@ -0,0 +1,210 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
use Aviat\AnimeClient\Types\HistoryItem;
use Aviat\Ion\Di\ContainerAware;
class AnimeHistoryTransformer {
use ContainerAware;
protected array $skipList = [];
/**
* Convert raw history
*
* @param array $data
* @return array
*/
public function transform(array $data): array
{
$output = [];
foreach ($data as $id => $entry)
{
if ( ! isset($entry['relationships']['anime']))
{
continue;
}
if (in_array($id, $this->skipList, FALSE))
{
continue;
}
if ($entry['attributes']['kind'] === 'progressed')
{
$output[] = $this->transformProgress($entry);
}
else if ($entry['attributes']['kind'] === 'updated')
{
$output[] = $this->transformUpdated($entry);
}
}
return $this->aggregate($output);
}
/**
* Combine consecutive 'progressed' events
*
* @param array $singles
* @return array
*/
protected function aggregate (array $singles): array
{
$output = [];
$count = count($singles);
for ($i = 0; $i < $count; $i++)
{
$entry = $singles[$i];
$prevTitle = $entry['title'];
$nextId = $i + 1;
if ($nextId < $count)
{
$entries = [];
$next = $singles[$nextId];
while (
$next['kind'] === 'progressed' &&
$next['title'] === $prevTitle
) {
$entries[] = $next;
$prevTitle = $next['title'];
if ($nextId + 1 < $count)
{
$nextId++;
$next = $singles[$nextId];
}
else
{
break;
}
}
}
if (count($entries) > 1)
{
$episodes = [];
foreach ($entries as $e)
{
$episodes[] = max($e['original']['attributes']['changedData']['progress']);
}
$firstEpisode = min($episodes);
$lastEpisode = max($episodes);
$title = $entries[0]['title'];
// Get rid of the single entry added before aggregating
// array_pop($output);
$action = (count($entries) > 3)
? "Marathoned episodes {$firstEpisode}-{$lastEpisode} of {$title}"
: "Watched episodes {$firstEpisode}-{$lastEpisode} of {$title}";
$output[] = HistoryItem::check([
'title' => $title,
'action' => $action,
'coverImg' => $entries[0]['coverImg'],
'isAggregate' => true,
'updated' => $entries[0]['updated'],
]);
// Skip the rest of the aggregate in the main loop
$i += count($entries);
$prevTitle = $title;
continue;
}
else
{
$prevTitle = $entry['title'];
$output[] = $entry;
}
}
return $output;
}
protected function transformProgress ($entry): array
{
$animeId = array_keys($entry['relationships']['anime'])[0];
$animeData = $entry['relationships']['anime'][$animeId]['attributes'];
$title = $this->linkTitle($animeData);
$imgUrl = 'images/anime/' . $animeId . '.webp';
$episode = max($entry['attributes']['changedData']['progress']);
return HistoryItem::check([
'action' => "Watched episode {$episode} of {$title}",
'coverImg' => $imgUrl,
'kind' => 'progressed',
'original' => $entry,
'title' => $title,
'updated' => $entry['attributes']['updatedAt'],
]);
}
protected function transformUpdated($entry): array
{
$animeId = array_keys($entry['relationships']['anime'])[0];
$animeData = $entry['relationships']['anime'][$animeId]['attributes'];
$title = $this->linkTitle($animeData);
$imgUrl = 'images/anime/' . $animeId . '.webp';
$kind = array_key_first($entry['attributes']['changedData']);
if ($kind === 'status')
{
$status = array_pop($entry['attributes']['changedData']['status']);
$statusName = AnimeWatchingStatus::KITSU_TO_TITLE[$status];
if ($statusName === 'Completed')
{
return HistoryItem::check([
'action' => "Completed {$title}",
'coverImg' => $imgUrl,
'kind' => 'updated',
'original' => $entry,
'title' => $title,
'updated' => $entry['attributes']['updatedAt'],
]);
}
return HistoryItem::check([
'action' => "Set status of {$title} to {$statusName}",
'coverImg' => $imgUrl,
'kind' => 'updated',
'original' => $entry,
'title' => $title,
'updated' => $entry['attributes']['updatedAt'],
]);
}
return $entry;
}
protected function linkTitle (array $animeData): string
{
$url = '/anime/details/' . $animeData['slug'];
$helper = $this->getContainer()->get('html-helper');
return $helper->a($url, $animeData['canonicalTitle'], ['id' => $animeData['slug']]);
}
}

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -22,6 +22,7 @@ use Aviat\AnimeClient\Types\{
AnimeListItem AnimeListItem
}; };
use Aviat\Ion\Transformer\AbstractTransformer; use Aviat\Ion\Transformer\AbstractTransformer;
use Aviat\Ion\Type\StringType;
/** /**
* Transformer for anime list * Transformer for anime list
@ -100,7 +101,7 @@ final class AnimeListTransformer extends AbstractTransformer {
'title' => $title, 'title' => $title,
'titles' => $titles, 'titles' => $titles,
'slug' => $anime['slug'], 'slug' => $anime['slug'],
'show_type' => (string)$this->string($anime['subtype'])->upperCaseFirst(), 'show_type' => (string)StringType::from($anime['subtype'])->upperCaseFirst(),
'cover_image' => $anime['posterImage']['small'], 'cover_image' => $anime['posterImage']['small'],
'genres' => $genres, 'genres' => $genres,
'streaming_links' => $streamingLinks, 'streaming_links' => $streamingLinks,

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -19,6 +19,7 @@ namespace Aviat\AnimeClient\API\Kitsu\Transformer;
use Aviat\AnimeClient\API\{JsonAPI, Kitsu}; use Aviat\AnimeClient\API\{JsonAPI, Kitsu};
use Aviat\AnimeClient\Types\AnimePage; use Aviat\AnimeClient\Types\AnimePage;
use Aviat\Ion\Transformer\AbstractTransformer; use Aviat\Ion\Transformer\AbstractTransformer;
use Aviat\Ion\Type\StringType;
/** /**
* Transformer for anime description page * Transformer for anime description page
@ -114,7 +115,7 @@ final class AnimeTransformer extends AbstractTransformer {
'genres' => $item['genres'], 'genres' => $item['genres'],
'id' => $item['id'], 'id' => $item['id'],
'included' => $item['included'], 'included' => $item['included'],
'show_type' => (string)$this->string($item['showType'])->upperCaseFirst(), 'show_type' => (string)StringType::from($item['showType'])->upperCaseFirst(),
'slug' => $item['slug'], 'slug' => $item['slug'],
'staff' => $staff, 'staff' => $staff,
'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']), 'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']),

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -21,16 +21,13 @@ use Aviat\AnimeClient\Types\{
FormItem, FormItemData, FormItem, FormItemData,
MangaListItem, MangaListItemDetail MangaListItem, MangaListItemDetail
}; };
use Aviat\Ion\StringWrapper;
use Aviat\Ion\Transformer\AbstractTransformer; use Aviat\Ion\Transformer\AbstractTransformer;
use Aviat\Ion\Type\StringType;
/** /**
* Data transformation class for zippered Hummingbird manga * Data transformation class for zippered Hummingbird manga
*/ */
final class MangaListTransformer extends AbstractTransformer { final class MangaListTransformer extends AbstractTransformer {
use StringWrapper;
/** /**
* Remap zipped anime data to a more logical form * Remap zipped anime data to a more logical form
* *
@ -103,7 +100,7 @@ final class MangaListTransformer extends AbstractTransformer {
'slug' => $manga['slug'], 'slug' => $manga['slug'],
'title' => $title, 'title' => $title,
'titles' => $titles, 'titles' => $titles,
'type' => (string)$this->string($manga['subtype'])->upperCaseFirst(), 'type' => (string)StringType::from($manga['subtype'])->upperCaseFirst(),
'url' => 'https://kitsu.io/manga/' . $manga['slug'], 'url' => 'https://kitsu.io/manga/' . $manga['slug'],
]), ]),
'reading_status' => $item['attributes']['status'], 'reading_status' => $item['attributes']['status'],

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -33,7 +33,7 @@ final class ParallelAPIRequest {
* *
* @var array * @var array
*/ */
private $requests = []; private array $requests = [];
/** /**
* Add a request * Add a request

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -213,9 +213,9 @@ function checkFolderPermissions(ConfigInterface $config): array
/** /**
* Get an API Client, with better defaults * Get an API Client, with better defaults
* *
* @return DefaultClient * @return HttpClient
*/ */
function getApiClient () function getApiClient (): HttpClient
{ {
static $client; static $client;
@ -290,7 +290,7 @@ function getLocalImg ($kitsuUrl, $webp = TRUE): string
* @param int $height * @param int $height
* @param string $text * @param string $text
*/ */
function createPlaceholderImage ($path, $width, $height, $text = 'Image Unavailable'): void function createPlaceholderImage ($path, ?int $width, ?int $height, $text = 'Image Unavailable'): void
{ {
$width = $width ?? 200; $width = $width ?? 200;
$height = $height ?? 200; $height = $height ?? 200;

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -29,9 +29,9 @@ use Aviat\Ion\Config;
use Aviat\Ion\Di\{Container, ContainerAware}; use Aviat\Ion\Di\{Container, ContainerAware};
use ConsoleKit\{Command, ConsoleException}; use ConsoleKit\{Command, ConsoleException};
use ConsoleKit\Widgets\Box; use ConsoleKit\Widgets\Box;
use Laminas\Diactoros\{Response, ServerRequestFactory};
use Monolog\Handler\RotatingFileHandler; use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger; use Monolog\Logger;
use Zend\Diactoros\{Response, ServerRequestFactory};
/** /**
* Base class for console command setup * Base class for console command setup

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -44,13 +44,13 @@ final class SyncLists extends BaseCommand {
* Model for making requests to Anilist API * Model for making requests to Anilist API
* @var AnilistModel * @var AnilistModel
*/ */
protected $anilistModel; protected AnilistModel $anilistModel;
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* @var KitsuModel * @var KitsuModel
*/ */
protected $kitsuModel; protected KitsuModel $kitsuModel;
/** /**
* Run the Kitsu <=> Anilist sync script * Run the Kitsu <=> Anilist sync script

View File

@ -4,20 +4,20 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
namespace Aviat\AnimeClient\Command; namespace Aviat\AnimeClient\Command;
use Aviat\AnimeClient\API\JsonAPI; use Aviat\AnimeClient\API\JsonAPI;
use Aviat\AnimeClient\API\Kitsu\Model; use Aviat\AnimeClient\API\Kitsu\Model as KitsuModel;
use Aviat\AnimeClient\Controller\Images; use Aviat\AnimeClient\Controller\Images;
/** /**
@ -27,14 +27,14 @@ use Aviat\AnimeClient\Controller\Images;
final class UpdateThumbnails extends ClearThumbnails { final class UpdateThumbnails extends ClearThumbnails {
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* @var Model * @var KitsuModel
*/ */
protected $kitsuModel; protected KitsuModel $kitsuModel;
/** /**
* The default controller, which has the method to cache the images * The default controller, which has the method to cache the images
*/ */
protected $controller; protected Images $controller;
public function execute(array $args, array $options = []): void public function execute(array $args, array $options = []): void
{ {

View File

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

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -21,6 +21,7 @@ use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuWatchingStatus; use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuWatchingStatus;
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus; use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
use Aviat\AnimeClient\Model\Anime as AnimeModel;
use Aviat\AnimeClient\Types\FormItem; use Aviat\AnimeClient\Types\FormItem;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\ContainerException; use Aviat\Ion\Di\Exception\ContainerException;
@ -29,6 +30,7 @@ use Aviat\Ion\Json;
use InvalidArgumentException; use InvalidArgumentException;
use Throwable; use Throwable;
use TypeError;
/** /**
* Controller for Anime-related pages * Controller for Anime-related pages
@ -37,9 +39,9 @@ final class Anime extends BaseController {
/** /**
* The anime list model * The anime list model
* @var \Aviat\AnimeClient\Model\Anime $model * @var AnimeModel $model
*/ */
protected $model; protected AnimeModel $model;
/** /**
* Constructor * Constructor
@ -337,7 +339,7 @@ final class Anime extends BaseController {
'data' => $data, 'data' => $data,
]); ]);
} }
catch (\TypeError $e) catch (TypeError $e)
{ {
$this->notFound( $this->notFound(
$this->config->get('whose_list') . $this->config->get('whose_list') .
@ -347,15 +349,5 @@ final class Anime extends BaseController {
); );
} }
} }
/**
* Find anime matching the selected genre
*
* @param string $genre
*/
public function genre(string $genre): void
{
// @TODO: implement
}
} }
// End of AnimeController.php // End of AnimeController.php

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -38,13 +38,13 @@ final class AnimeCollection extends BaseController {
* The anime collection model * The anime collection model
* @var AnimeCollectionModel $animeCollectionModel * @var AnimeCollectionModel $animeCollectionModel
*/ */
private $animeCollectionModel; private AnimeCollectionModel $animeCollectionModel;
/** /**
* The anime API model * The anime API model
* @var AnimeModel $animeModel * @var AnimeModel $animeModel
*/ */
private $animeModel; private AnimeModel $animeModel;
/** /**
* Constructor * Constructor

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -32,7 +32,7 @@ class Character extends BaseController {
/** /**
* @var Model * @var Model
*/ */
private $model; private Model $model;
/** /**
* Character constructor. * Character constructor.

View File

@ -0,0 +1,84 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 7.4
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Controller;
use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\Model\Anime as AnimeModel;
use Aviat\AnimeClient\Model\Manga as MangaModel;
use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException;
/**
* Controller for Anime-related pages
*/
final class History extends BaseController {
/**
* The anime list model
* @var AnimeModel
*/
protected AnimeModel $animeModel;
/**
* The manga list model
* @var MangaModel
*/
protected MangaModel $mangaModel;
/**
* Constructor
*
* @param ContainerInterface $container
* @throws ContainerException
* @throws NotFoundException
*/
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
$this->animeModel = $container->get('anime-model');
$this->mangaModel = $container->get('manga-model');
}
public function anime(): void
{
// $this->outputJSON($this->animeModel->getHistory());
// return;
$this->outputHTML('history/anime', [
'title' => $this->formatTitle(
$this->config->get('whose_list') . "'s Anime List",
'Anime',
'Watching History'
),
'items' => $this->animeModel->getHistory(),
]);
}
public function manga(): void
{
$this->outputJSON($this->mangaModel->getHistory());
return;
$this->outputHTML('history/manga', [
'title' => $this->formatTitle(
$this->config->get('whose_list') . "'s Manga List",
'Manga',
'Reading History'
),
'items' => $this->mangaModel->getHistory(),
]);
}
}

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -38,7 +38,7 @@ final class Manga extends Controller {
* The manga model * The manga model
* @var MangaModel $model * @var MangaModel $model
*/ */
protected $model; protected MangaModel $model;
/** /**
* Constructor * Constructor
@ -337,14 +337,11 @@ final class Manga extends Controller {
]); ]);
} }
/** public function history(): void
* Find manga matching the selected genre
*
* @param string $genre
*/
public function genre(string $genre): void
{ {
// @TODO: implement $data = $this->model->getHistory();
$this->outputJSON($data);
} }
} }
// End of MangaController.php // End of MangaController.php

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -32,7 +32,7 @@ final class People extends BaseController {
/** /**
* @var Model * @var Model
*/ */
private $model; private Model $model;
/** /**
* People constructor. * People constructor.

View File

@ -4,21 +4,22 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use Aura\Router\Exception\RouteNotFound; use Aura\Router\Exception\RouteNotFound;
use Aviat\AnimeClient\API\Anilist\Model; use Aviat\AnimeClient\API\Anilist\Model as AnilistModel;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\Model\Settings as SettingsModel;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\ContainerException; use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException; use Aviat\Ion\Di\Exception\NotFoundException;
@ -29,14 +30,14 @@ use Aviat\Ion\Di\Exception\NotFoundException;
final class Settings extends BaseController { final class Settings extends BaseController {
/** /**
* @var Model * @var AnilistModel
*/ */
private $anilistModel; private AnilistModel $anilistModel;
/** /**
* @var \Aviat\AnimeClient\Model\Settings * @var SettingsModel
*/ */
private $settingsModel; private SettingsModel $settingsModel;
/** /**
* Settings constructor. * Settings constructor.

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -32,7 +32,7 @@ final class User extends BaseController {
/** /**
* @var Model * @var Model
*/ */
private $kitsuModel; private Model $kitsuModel;
/** /**
* User constructor. * User constructor.

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -18,13 +18,12 @@ namespace Aviat\AnimeClient;
use function Aviat\Ion\_dir; use function Aviat\Ion\_dir;
use Aura\Router\{Matcher, Route, Rule}; use Aura\Router\{Map, Matcher, Route, Rule};
use Aviat\AnimeClient\API\FailedResponseException; use Aviat\AnimeClient\API\FailedResponseException;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Friend; use Aviat\Ion\Friend;
use Aviat\Ion\StringWrapper; use Aviat\Ion\Type\StringType;
use LogicException; use LogicException;
use ReflectionException; use ReflectionException;
@ -33,31 +32,29 @@ use ReflectionException;
*/ */
final class Dispatcher extends RoutingBase { final class Dispatcher extends RoutingBase {
use StringWrapper;
/** /**
* The route-matching object * The route-matching object
* @var object $router * @var Map $router
*/ */
protected $router; protected Map $router;
/** /**
* The route matcher * The route matcher
* @var Matcher $matcher * @var Matcher $matcher
*/ */
protected $matcher; protected Matcher $matcher;
/** /**
* Routing array * Routing array
* @var array * @var array
*/ */
protected $routes; protected array $routes;
/** /**
* Routes added to router * Routes added to router
* @var array $outputRoutes * @var array $outputRoutes
*/ */
protected $outputRoutes; protected array $outputRoutes;
/** /**
* Constructor * Constructor
@ -254,7 +251,7 @@ final class Dispatcher extends RoutingBase {
foreach ($classFiles as $file) foreach ($classFiles as $file)
{ {
$rawClassName = basename(str_replace('.php', '', $file)); $rawClassName = basename(str_replace('.php', '', $file));
$path = (string)$this->string($rawClassName)->dasherize(); $path = (string)StringType::from($rawClassName)->dasherize();
$className = trim($defaultNamespace . '\\' . $rawClassName, '\\'); $className = trim($defaultNamespace . '\\' . $rawClassName, '\\');
$controllers[$path] = $className; $controllers[$path] = $className;

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -30,7 +30,7 @@ final class FormGenerator {
* *
* @var HelperLocator * @var HelperLocator
*/ */
private $helper; private HelperLocator $helper;
/** /**
* FormGenerator constructor. * FormGenerator constructor.
@ -93,6 +93,9 @@ final class FormGenerator {
$params['type'] = 'select'; $params['type'] = 'select';
$params['options'] = array_flip($form['options']); $params['options'] = array_flip($form['options']);
break; break;
default:
break;
} }
foreach (['readonly', 'disabled'] as $key) foreach (['readonly', 'disabled'] as $key)

View File

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

View File

@ -4,23 +4,24 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
namespace Aviat\AnimeClient; namespace Aviat\AnimeClient;
use Aviat\Ion\{ArrayWrapper, StringWrapper};
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
use Aura\Html\HelperLocator; use Aura\Html\HelperLocator;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Exception\ConfigException; use Aviat\Ion\Exception\ConfigException;
use Aviat\Ion\Type\ArrayType;
use Aviat\Ion\Type\StringType;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
/** /**
@ -28,22 +29,19 @@ use Psr\Http\Message\RequestInterface;
*/ */
final class MenuGenerator extends UrlGenerator { final class MenuGenerator extends UrlGenerator {
use ArrayWrapper;
use StringWrapper;
/** /**
* Html generation helper * Html generation helper
* *
* @var HelperLocator * @var HelperLocator
*/ */
protected $helper; protected HelperLocator $helper;
/** /**
* Request object * Request object
* *
* @var RequestInterface * @var RequestInterface
*/ */
protected $request; protected RequestInterface $request;
/** /**
* MenuGenerator constructor. * MenuGenerator constructor.
@ -74,8 +72,8 @@ final class MenuGenerator extends UrlGenerator {
$parsed[$name] = []; $parsed[$name] = [];
foreach ($menu['items'] as $pathName => $partialPath) foreach ($menu['items'] as $pathName => $partialPath)
{ {
$title = (string)$this->string($pathName)->humanize()->titleize(); $title = (string)StringType::from($pathName)->humanize()->titleize();
$parsed[$name][$title] = (string)$this->string($menu['route_prefix'])->append($partialPath); $parsed[$name][$title] = (string)StringType::from($menu['route_prefix'])->append($partialPath);
} }
} }
@ -95,7 +93,7 @@ final class MenuGenerator extends UrlGenerator {
$parsedConfig = $this->parseConfig($menus); $parsedConfig = $this->parseConfig($menus);
// Bail out early on invalid menu // Bail out early on invalid menu
if ( ! $this->arr($parsedConfig)->hasKey($menu)) if ( ! ArrayType::from($parsedConfig)->hasKey($menu))
{ {
return ''; return '';
} }
@ -104,7 +102,7 @@ final class MenuGenerator extends UrlGenerator {
foreach ($menuConfig as $title => $path) foreach ($menuConfig as $title => $path)
{ {
$has = $this->string($this->path())->contains($path); $has = StringType::from($this->path())->contains($path);
$selected = ($has && mb_strlen($this->path()) >= mb_strlen($path)); $selected = ($has && mb_strlen($this->path()) >= mb_strlen($path));
$link = $this->helper->a($this->url($path), $title); $link = $this->helper->a($this->url($path), $title);

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -29,6 +29,7 @@ use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Json; use Aviat\Ion\Json;
use Throwable; use Throwable;
use function is_array;
/** /**
* Model for handling requests dealing with the anime list * Model for handling requests dealing with the anime list
@ -40,21 +41,21 @@ class Anime extends API {
* *
* @var boolean * @var boolean
*/ */
protected $anilistEnabled; protected bool $anilistEnabled;
/** /**
* Model for making requests to Anilist API * Model for making requests to Anilist API
* *
* @var AnilistModel * @var AnilistModel
*/ */
protected $anilistModel; protected AnilistModel $anilistModel;
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* *
* @var KitsuModel * @var KitsuModel
*/ */
protected $kitsuModel; protected KitsuModel $kitsuModel;
/** /**
* Anime constructor. * Anime constructor.
@ -128,6 +129,16 @@ class Anime extends API {
return $this->kitsuModel->getAnimeById($animeId); return $this->kitsuModel->getAnimeById($animeId);
} }
/**
* Get recent watch history
*
* @return array
*/
public function getHistory(): array
{
return $this->kitsuModel->getAnimeHistory();
}
/** /**
* Search for anime by name * Search for anime by name
* *
@ -151,7 +162,7 @@ class Anime extends API {
$item = $this->kitsuModel->getListItem($itemId); $item = $this->kitsuModel->getListItem($itemId);
$array = $item->toArray(); $array = $item->toArray();
if (\is_array($array['notes'])) if (is_array($array['notes']))
{ {
$array['notes'] = ''; $array['notes'] = '';
} }

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -29,7 +29,7 @@ final class AnimeCollection extends Collection {
* Anime API Model * Anime API Model
* @var Anime $animeModel * @var Anime $animeModel
*/ */
protected $animeModel; protected Anime $animeModel;
/** /**
* Create the collection model * Create the collection model
@ -367,7 +367,7 @@ final class AnimeCollection extends Collection {
} }
catch (PDOException $e) {} catch (PDOException $e) {}
$this->db->reset_query(); $this->db->resetQuery();
return $output; return $output;
} }
@ -446,7 +446,7 @@ final class AnimeCollection extends Collection {
try try
{ {
$this->db->insert_batch('genres', $insert); $this->db->insertBatch('genres', $insert);
} }
catch (PDOException $e) catch (PDOException $e)
{ {
@ -486,7 +486,7 @@ final class AnimeCollection extends Collection {
$genres[$genre['id']] = $genre['genre']; $genres[$genre['id']] = $genre['genre'];
} }
$this->db->reset_query(); $this->db->resetQuery();
return $genres; return $genres;
} }
@ -509,13 +509,14 @@ final class AnimeCollection extends Collection {
if (array_key_exists($link['hummingbird_id'], $links)) if (array_key_exists($link['hummingbird_id'], $links))
{ {
$links[$link['hummingbird_id']][] = $link['genre_id']; $links[$link['hummingbird_id']][] = $link['genre_id'];
} else }
else
{ {
$links[$link['hummingbird_id']] = [$link['genre_id']]; $links[$link['hummingbird_id']] = [$link['genre_id']];
} }
} }
$this->db->reset_query(); $this->db->resetQuery();
return $links; return $links;
} }

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -19,7 +19,7 @@ namespace Aviat\AnimeClient\Model;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use PDOException; use PDOException;
use Query\Query_Builder_Interface; use Query\QueryBuilderInterface;
use function Query; use function Query;
/** /**
@ -29,15 +29,15 @@ class Collection extends DB {
/** /**
* The query builder object * The query builder object
* @var Query_Builder_Interface * @var QueryBuilderInterface
*/ */
protected $db; protected QueryBuilderInterface $db;
/** /**
* Whether the database is valid for querying * Whether the database is valid for querying
* @var boolean * @var boolean
*/ */
protected $validDatabase = FALSE; protected bool $validDatabase = FALSE;
/** /**
* Create a new collection object * Create a new collection object

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -26,6 +26,7 @@ use Aviat\AnimeClient\Types\{
MangaListItem, MangaListItem,
MangaPage MangaPage
}; };
use Aviat\AnimeClient\API\{Anilist, Kitsu};
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Json; use Aviat\Ion\Json;
@ -40,19 +41,19 @@ class Manga extends API {
* *
* @var boolean * @var boolean
*/ */
protected $anilistEnabled; protected bool $anilistEnabled;
/** /**
* Model for making requests to the Anilist API * Model for making requests to the Anilist API
* @var \Aviat\AnimeClient\API\Anilist\Model * @var Anilist\Model
*/ */
protected $anilistModel; protected Anilist\Model $anilistModel;
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* @var \Aviat\AnimeClient\API\Kitsu\Model * @var Kitsu\Model
*/ */
protected $kitsuModel; protected Kitsu\Model $kitsuModel;
/** /**
* Constructor * Constructor
@ -231,7 +232,7 @@ class Manga extends API {
} }
/** /**
* Search for anime by name * Search for manga by name
* *
* @param string $name * @param string $name
* @return array * @return array
@ -241,6 +242,16 @@ class Manga extends API {
return $this->kitsuModel->search('manga', $name); return $this->kitsuModel->search('manga', $name);
} }
/**
* Get recent reading history
*
* @return array
*/
public function getHistory(): array
{
return $this->kitsuModel->getMangaHistory();
}
/** /**
* Map transformed anime data to be organized by reading status * Map transformed anime data to be organized by reading status
* *

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @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 * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -25,16 +25,14 @@ use Aviat\AnimeClient\Types\{Config, UndefinedPropertyException};
use Aviat\Ion\ConfigInterface; use Aviat\Ion\ConfigInterface;
use Aviat\Ion\Di\ContainerAware; use Aviat\Ion\Di\ContainerAware;
use Aviat\Ion\StringWrapper;
/** /**
* Model for handling settings control panel * Model for handling settings control panel
*/ */
final class Settings { final class Settings {
use ContainerAware; use ContainerAware;
use StringWrapper;
private $config; private ConfigInterface $config;
public function __construct(ConfigInterface $config) public function __construct(ConfigInterface $config)
{ {

View File

@ -4,50 +4,48 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
namespace Aviat\AnimeClient; namespace Aviat\AnimeClient;
use Aviat\Ion\Config; use Aviat\Ion\ConfigInterface;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\ContainerException; use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException; use Aviat\Ion\Di\Exception\NotFoundException;
use Aviat\Ion\Exception\ConfigException; use Aviat\Ion\Exception\ConfigException;
use Aviat\Ion\StringWrapper; use Aviat\Ion\Type\StringType;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\RequestInterface;
/** /**
* Base for routing/url classes * Base for routing/url classes
*/ */
class RoutingBase { class RoutingBase {
use StringWrapper;
/** /**
* Injection Container * Injection Container
* @var ContainerInterface $container * @var ContainerInterface $container
*/ */
protected $container; protected ContainerInterface $container;
/** /**
* Config Object * Config Object
* @var Config * @var ConfigInterface
*/ */
protected $config; protected ConfigInterface $config;
/** /**
* Class wrapper for input superglobals * Class wrapper for input superglobals
* @var ServerRequestInterface * @var RequestInterface
*/ */
protected $request; protected RequestInterface $request;
/** /**
* Constructor * Constructor
@ -73,7 +71,7 @@ class RoutingBase {
public function path(): string public function path(): string
{ {
$path = $this->request->getUri()->getPath(); $path = $this->request->getUri()->getPath();
$cleanedPath = $this->string($path) $cleanedPath = StringType::from($path)
->replace('%20', '') ->replace('%20', '')
->trim() ->trim()
->trimRight('/') ->trimRight('/')

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -31,6 +31,24 @@ abstract class AbstractType implements ArrayAccess, Countable {
return new static($properties); return new static($properties);
} }
/**
* Check the shape of the object, and return the array equivalent
*
* @param array $data
* @return array|null
*/
final public static function check($data = []): ?array
{
$currentClass = static::class;
if (get_parent_class($currentClass) !== FALSE)
{
return (new $currentClass($data))->toArray();
}
return NULL;
}
/** /**
* Sets the properties by using the constructor * Sets the properties by using the constructor
* *
@ -61,7 +79,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* @param $name * @param $name
* @return bool * @return bool
*/ */
public function __isset($name): bool final public function __isset($name): bool
{ {
return property_exists($this, $name) && isset($this->$name); return property_exists($this, $name) && isset($this->$name);
} }
@ -73,7 +91,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* @param mixed $value * @param mixed $value
* @return void * @return void
*/ */
public function __set($name, $value): void final public function __set($name, $value): void
{ {
$setterMethod = 'set' . ucfirst($name); $setterMethod = 'set' . ucfirst($name);
@ -99,7 +117,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* @param string $name * @param string $name
* @return mixed * @return mixed
*/ */
public function __get($name) final public function __get($name)
{ {
// Be a bit more lenient here, so that you can easily typecast missing // Be a bit more lenient here, so that you can easily typecast missing
// values to reasonable defaults, and not have to resort to array indexes // values to reasonable defaults, and not have to resort to array indexes
@ -122,7 +140,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* @param $offset * @param $offset
* @return bool * @return bool
*/ */
public function offsetExists($offset): bool final public function offsetExists($offset): bool
{ {
return $this->__isset($offset); return $this->__isset($offset);
} }
@ -133,7 +151,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* @param $offset * @param $offset
* @return mixed * @return mixed
*/ */
public function offsetGet($offset) final public function offsetGet($offset)
{ {
return $this->__get($offset); return $this->__get($offset);
} }
@ -144,7 +162,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* @param $offset * @param $offset
* @param $value * @param $value
*/ */
public function offsetSet($offset, $value): void final public function offsetSet($offset, $value): void
{ {
$this->__set($offset, $value); $this->__set($offset, $value);
} }
@ -154,7 +172,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* *
* @param $offset * @param $offset
*/ */
public function offsetUnset($offset): void final public function offsetUnset($offset): void
{ {
if ($this->offsetExists($offset)) if ($this->offsetExists($offset))
{ {
@ -167,7 +185,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* *
* @return int * @return int
*/ */
public function count(): int final public function count(): int
{ {
$keys = array_keys($this->toArray()); $keys = array_keys($this->toArray());
return count($keys); return count($keys);
@ -179,7 +197,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* @param mixed $parent * @param mixed $parent
* @return mixed * @return mixed
*/ */
public function toArray($parent = null) final public function toArray($parent = null)
{ {
$object = $parent ?? $this; $object = $parent ?? $this;
@ -205,7 +223,7 @@ abstract class AbstractType implements ArrayAccess, Countable {
* *
* @return bool * @return bool
*/ */
public function isEmpty(): bool final public function isEmpty(): bool
{ {
foreach ($this as $value) foreach ($this as $value)
{ {

View File

@ -4,13 +4,13 @@
* *
* An API client for Kitsu to manage anime and manga watch lists * An API client for Kitsu to manage anime and manga watch lists
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package HummingbirdAnimeClient * @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2020 Timothy J. Warren * @copyright 2015 - 2020 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.2 * @version 5
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/ */
@ -25,85 +25,85 @@ class Anime extends AbstractType {
/** /**
* @var string * @var string
*/ */
public $age_rating; public ?string $age_rating = '';
/** /**
* @var string * @var string
*/ */
public $age_rating_guide; public ?string $age_rating_guide = '';
/** /**
* @var string * @var string
*/ */
public $cover_image; public string $cover_image = '';
/** /**
* @var string|int * @var string|int
*/ */
public $episode_count; public ?int $episode_count = 13;
/** /**
* @var string|int * @var string|int
*/ */
public $episode_length; public ?int $episode_length = 24;
/** /**
* @var array * @var array
*/ */
public $genres; public array $genres = [];
/** /**
* @var string * @var string|int
*/ */
public $id; public $id = '';
/** /**
* @var array * @var array
*/ */
public $included; public array $included = [];
/** /**
* @var string * @var string
*/ */
public $show_type; public string $show_type = '';
/** /**
* @var string * @var string
*/ */
public $slug; public string $slug = '';
/** /**
* @var AnimeAiringStatus::NOT_YET_AIRED | AnimeAiringStatus::AIRING | AnimeAiringStatus::FINISHED_AIRING * @var AnimeAiringStatus
*/ */
public $status; public string $status = AnimeAiringStatus::FINISHED_AIRING;
/** /**
* @var array * @var array
*/ */
public $streaming_links; public ?array $streaming_links = [];
/** /**
* @var string * @var string
*/ */
public $synopsis; public string $synopsis = '';
/** /**
* @var string * @var string
*/ */
public $title; public string $title = '';
/** /**
* @var array * @var array
*/ */
public $titles; public array $titles = [];
/** /**
* @var string * @var string
*/ */
public $trailer_id; public ?string $trailer_id = '';
/** /**
* @var string * @var string
*/ */
public $url; public string $url = '';
} }

View File

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

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