Version 5.1 - All the GraphQL #32
1
.gitignore
vendored
1
.gitignore
vendored
@ -146,3 +146,4 @@ public/images/manga/**
|
|||||||
public/images/characters/**
|
public/images/characters/**
|
||||||
public/images/people/**
|
public/images/people/**
|
||||||
public/mal_mappings.json
|
public/mal_mappings.json
|
||||||
|
.phpunit.result.cache
|
16
.travis.yml
16
.travis.yml
@ -4,23 +4,21 @@ install:
|
|||||||
- composer install --ignore-platform-reqs
|
- composer install --ignore-platform-reqs
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 7.1
|
|
||||||
- 7.2
|
|
||||||
- 7.3
|
- 7.3
|
||||||
|
- 7.4
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
- phpdbg -qrr -- vendor/bin/phpunit -c build
|
- php vendor/bin/phpunit -c build
|
||||||
|
|
||||||
after_script:
|
#after_script:
|
||||||
- CODECLIMATE_REPO_TOKEN=2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 vendor/bin/test-reporter
|
# - CODECLIMATE_REPO_TOKEN=2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 vendor/bin/test-reporter
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: nightly
|
- php: nightly
|
||||||
- php: hhvm
|
|
||||||
|
|
||||||
addons:
|
#addons:
|
||||||
code_climate:
|
# code_climate:
|
||||||
repo_token: 2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058
|
# repo_token: 2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058
|
@ -1,6 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version 4.2
|
||||||
|
* Updated dependencies
|
||||||
|
* Updated PHP requirement to 7.3
|
||||||
|
|
||||||
## Version 4.1
|
## Version 4.1
|
||||||
|
* Added optional dark theme
|
||||||
* Removed MAL integration, added Anilist Integration
|
* Removed MAL integration, added Anilist Integration
|
||||||
* Now uses WebP cache images when the browser supports it
|
* Now uses WebP cache images when the browser supports it
|
||||||
* Replaces JS minifier with pre-minified scripts (Removes the need for one caching folder, too)
|
* Replaces JS minifier with pre-minified scripts (Removes the need for one caching folder, too)
|
||||||
|
74
Jenkinsfile
vendored
74
Jenkinsfile
vendored
@ -1,36 +1,13 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent none
|
agent none
|
||||||
stages {
|
stages {
|
||||||
stage('PHP 7.1') {
|
stage('setup') {
|
||||||
agent {
|
agent any
|
||||||
docker {
|
|
||||||
image 'php:7.1-alpine'
|
|
||||||
args '-u root --privileged'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
steps {
|
||||||
sh 'chmod +x ./build/docker_install.sh'
|
|
||||||
sh 'sh build/docker_install.sh'
|
|
||||||
sh 'apk add --no-cache php7-phpdbg'
|
|
||||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
sh 'curl -sS https://getcomposer.org/installer | php'
|
||||||
|
sh 'rm -rf ./vendor'
|
||||||
|
sh 'rm -f composer.lock'
|
||||||
sh 'php composer.phar install --ignore-platform-reqs'
|
sh 'php composer.phar install --ignore-platform-reqs'
|
||||||
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('PHP 7.2') {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'php:7.2-alpine'
|
|
||||||
args '-u root --privileged'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh 'chmod +x ./build/docker_install.sh'
|
|
||||||
sh 'sh build/docker_install.sh'
|
|
||||||
sh 'apk add --no-cache php7-phpdbg'
|
|
||||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
|
||||||
sh 'php composer.phar install --ignore-platform-reqs'
|
|
||||||
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('PHP 7.3') {
|
stage('PHP 7.3') {
|
||||||
@ -41,12 +18,43 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
sh 'chmod +x ./build/docker_install.sh'
|
sh 'apk add --no-cache git'
|
||||||
sh 'sh build/docker_install.sh'
|
sh 'php ./vendor/bin/phpunit --colors=never'
|
||||||
sh 'apk add --no-cache php7-phpdbg'
|
}
|
||||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
}
|
||||||
sh 'php composer.phar install --ignore-platform-reqs'
|
stage('PHP 7.4') {
|
||||||
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'php:7.4-alpine'
|
||||||
|
args '-u root --privileged'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'apk add --no-cache git'
|
||||||
|
sh 'php ./vendor/bin/phpunit --colors=never'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Latest PHP') {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'php:alpine'
|
||||||
|
args '-u root --privileged'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'apk add --no-cache git'
|
||||||
|
sh 'php ./vendor/bin/phpunit --colors=never'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Coverage') {
|
||||||
|
agent any
|
||||||
|
steps {
|
||||||
|
sh 'php composer.phar run-script coverage'
|
||||||
|
step([
|
||||||
|
$class: 'CloverPublisher',
|
||||||
|
cloverReportDir: '',
|
||||||
|
cloverReportFileName: 'build/logs/clover.xml',
|
||||||
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
Update your anime/manga list on Kitsu.io and MyAnimeList.net
|
Update your anime/manga list on Kitsu.io and MyAnimeList.net
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/timw4mail/HummingBirdAnimeClient.svg?branch=master)](https://travis-ci.org/timw4mail/HummingBirdAnimeClient)
|
[![Build Status](https://travis-ci.org/timw4mail/HummingBirdAnimeClient.svg?branch=master)](https://travis-ci.org/timw4mail/HummingBirdAnimeClient)
|
||||||
[![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=aviat/HummingBirdAnimeClient/develop)](https://jenkins.timshomepage.net/job/aviat/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.1+
|
* PHP 7.3+
|
||||||
* 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
|
||||||
|
|
||||||
|
83
RoboFile.php
83
RoboFile.php
@ -54,12 +54,13 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Do static analysis tasks
|
* Do static analysis tasks
|
||||||
*/
|
*/
|
||||||
public function analyze()
|
public function analyze(): void
|
||||||
{
|
{
|
||||||
$this->prepare();
|
$this->prepare();
|
||||||
$this->lint();
|
$this->lint();
|
||||||
$this->phploc(TRUE);
|
$this->phploc(TRUE);
|
||||||
$this->phpcs(TRUE);
|
$this->phpcs(TRUE);
|
||||||
|
$this->phpmd(TRUE);
|
||||||
$this->dependencyReport();
|
$this->dependencyReport();
|
||||||
$this->phpcpdReport();
|
$this->phpcpdReport();
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Run all tests, generate coverage, generate docs, generate code statistics
|
* Run all tests, generate coverage, generate docs, generate code statistics
|
||||||
*/
|
*/
|
||||||
public function build()
|
public function build(): void
|
||||||
{
|
{
|
||||||
$this->analyze();
|
$this->analyze();
|
||||||
$this->coverage();
|
$this->coverage();
|
||||||
@ -77,19 +78,19 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Cleanup temporary files
|
* Cleanup temporary files
|
||||||
*/
|
*/
|
||||||
public function clean()
|
public function clean(): void
|
||||||
{
|
{
|
||||||
$cleanFiles = [
|
$cleanFiles = [
|
||||||
'build/humbug.json',
|
'build/humbug.json',
|
||||||
'build/humbug-log.txt',
|
'build/humbug-log.txt',
|
||||||
];
|
];
|
||||||
array_map(function ($file) {
|
array_map(static function ($file) {
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
}, $cleanFiles);
|
}, $cleanFiles);
|
||||||
|
|
||||||
// So the task doesn't complain,
|
// So the task doesn't complain,
|
||||||
// make any 'missing' dirs to cleanup
|
// make any 'missing' dirs to cleanup
|
||||||
array_map(function ($dir) {
|
array_map(static function ($dir) {
|
||||||
if ( ! is_dir($dir))
|
if ( ! is_dir($dir))
|
||||||
{
|
{
|
||||||
`mkdir -p {$dir}`;
|
`mkdir -p {$dir}`;
|
||||||
@ -103,7 +104,7 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Run unit tests and generate coverage reports
|
* Run unit tests and generate coverage reports
|
||||||
*/
|
*/
|
||||||
public function coverage()
|
public function coverage(): void
|
||||||
{
|
{
|
||||||
$this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']);
|
$this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']);
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Generate documentation with phpdox
|
* Generate documentation with phpdox
|
||||||
*/
|
*/
|
||||||
public function docs()
|
public function docs(): void
|
||||||
{
|
{
|
||||||
$cmd_parts = [
|
$cmd_parts = [
|
||||||
'vendor/bin/phpdox',
|
'vendor/bin/phpdox',
|
||||||
@ -122,11 +123,11 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Verify that source files are valid
|
* Verify that source files are valid
|
||||||
*/
|
*/
|
||||||
public function lint()
|
public function lint(): void
|
||||||
{
|
{
|
||||||
$files = $this->getAllSourceFiles();
|
$files = $this->getAllSourceFiles();
|
||||||
|
|
||||||
$chunks = array_chunk($files, 12);
|
$chunks = array_chunk($files, (int)shell_exec('getconf _NPROCESSORS_ONLN'));
|
||||||
|
|
||||||
foreach($chunks as $chunk)
|
foreach($chunks as $chunk)
|
||||||
{
|
{
|
||||||
@ -139,7 +140,7 @@ class RoboFile extends Tasks {
|
|||||||
*
|
*
|
||||||
* @param bool $report - if true, generates reports instead of direct output
|
* @param bool $report - if true, generates reports instead of direct output
|
||||||
*/
|
*/
|
||||||
public function phpcs($report = FALSE)
|
public function phpcs($report = FALSE): void
|
||||||
{
|
{
|
||||||
$report_cmd_parts = [
|
$report_cmd_parts = [
|
||||||
'vendor/bin/phpcs',
|
'vendor/bin/phpcs',
|
||||||
@ -157,12 +158,36 @@ class RoboFile extends Tasks {
|
|||||||
$this->_run($cmd_parts);
|
$this->_run($cmd_parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function phpmd($report = FALSE): void
|
||||||
|
{
|
||||||
|
$report_cmd_parts = [
|
||||||
|
'vendor/bin/phpmd',
|
||||||
|
'./src',
|
||||||
|
'xml',
|
||||||
|
'cleancode,codesize,controversial,design,naming,unusedcode',
|
||||||
|
'--exclude ParallelAPIRequest',
|
||||||
|
'--reportfile ./build/logs/phpmd.xml'
|
||||||
|
];
|
||||||
|
|
||||||
|
$normal_cmd_parts = [
|
||||||
|
'vendor/bin/phpmd',
|
||||||
|
'./src',
|
||||||
|
'ansi',
|
||||||
|
'cleancode,codesize,controversial,design,naming,unusedcode',
|
||||||
|
'--exclude ParallelAPIRequest'
|
||||||
|
];
|
||||||
|
|
||||||
|
$cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts;
|
||||||
|
|
||||||
|
$this->_run($cmd_parts);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the phploc tool
|
* Run the phploc tool
|
||||||
*
|
*
|
||||||
* @param bool $report - if true, generates reports instead of direct output
|
* @param bool $report - if true, generates reports instead of direct output
|
||||||
*/
|
*/
|
||||||
public function phploc($report = FALSE)
|
public function phploc($report = FALSE): void
|
||||||
{
|
{
|
||||||
// Command for generating reports
|
// Command for generating reports
|
||||||
$report_cmd_parts = [
|
$report_cmd_parts = [
|
||||||
@ -190,7 +215,7 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Create temporary directories
|
* Create temporary directories
|
||||||
*/
|
*/
|
||||||
public function prepare()
|
public function prepare(): void
|
||||||
{
|
{
|
||||||
array_map([$this, '_mkdir'], $this->taskDirs);
|
array_map([$this, '_mkdir'], $this->taskDirs);
|
||||||
}
|
}
|
||||||
@ -198,35 +223,17 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Lint php files and run unit tests
|
* Lint php files and run unit tests
|
||||||
*/
|
*/
|
||||||
public function test()
|
public function test(): void
|
||||||
{
|
{
|
||||||
$this->lint();
|
$this->lint();
|
||||||
|
|
||||||
$this->_run(['phpunit']);
|
$this->_run(['phpunit']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Watches for file updates, and automatically runs appropriate actions
|
|
||||||
*/
|
|
||||||
public function watch()
|
|
||||||
{
|
|
||||||
$this->taskWatch()
|
|
||||||
->monitor('composer.json', function() {
|
|
||||||
$this->taskComposerUpdate()->run();
|
|
||||||
})
|
|
||||||
->monitor('src', function () {
|
|
||||||
$this->taskExec('test')->run();
|
|
||||||
})
|
|
||||||
->monitor('tests', function () {
|
|
||||||
$this->taskExec('test')->run();
|
|
||||||
})
|
|
||||||
->run();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create pdepend reports
|
* Create pdepend reports
|
||||||
*/
|
*/
|
||||||
protected function dependencyReport()
|
protected function dependencyReport(): void
|
||||||
{
|
{
|
||||||
$cmd_parts = [
|
$cmd_parts = [
|
||||||
'vendor/bin/pdepend',
|
'vendor/bin/pdepend',
|
||||||
@ -243,7 +250,7 @@ class RoboFile extends Tasks {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getAllSourceFiles()
|
protected function getAllSourceFiles(): array
|
||||||
{
|
{
|
||||||
$files = array_merge(
|
$files = array_merge(
|
||||||
glob_recursive('build/*.php'),
|
glob_recursive('build/*.php'),
|
||||||
@ -254,6 +261,10 @@ class RoboFile extends Tasks {
|
|||||||
glob('*.php')
|
glob('*.php')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$files = array_filter($files, static function(string $value) {
|
||||||
|
return strpos($value, '__snapshots__') === FALSE;
|
||||||
|
});
|
||||||
|
|
||||||
sort($files);
|
sort($files);
|
||||||
|
|
||||||
return $files;
|
return $files;
|
||||||
@ -264,7 +275,7 @@ class RoboFile extends Tasks {
|
|||||||
*
|
*
|
||||||
* @param array $chunk
|
* @param array $chunk
|
||||||
*/
|
*/
|
||||||
protected function parallelLint(array $chunk)
|
protected function parallelLint(array $chunk): void
|
||||||
{
|
{
|
||||||
$task = $this->taskParallelExec()
|
$task = $this->taskParallelExec()
|
||||||
->timeout(5)
|
->timeout(5)
|
||||||
@ -281,7 +292,7 @@ class RoboFile extends Tasks {
|
|||||||
/**
|
/**
|
||||||
* Generate copy paste detector report
|
* Generate copy paste detector report
|
||||||
*/
|
*/
|
||||||
protected function phpcpdReport()
|
protected function phpcpdReport(): void
|
||||||
{
|
{
|
||||||
$cmd_parts = [
|
$cmd_parts = [
|
||||||
'vendor/bin/phpcpd',
|
'vendor/bin/phpcpd',
|
||||||
@ -298,7 +309,7 @@ class RoboFile extends Tasks {
|
|||||||
* @param array $cmd_parts - command arguments
|
* @param array $cmd_parts - command arguments
|
||||||
* @param string $join_on - what to join the command arguments with
|
* @param string $join_on - what to join the command arguments with
|
||||||
*/
|
*/
|
||||||
protected function _run(array $cmd_parts, $join_on = ' ')
|
protected function _run(array $cmd_parts, $join_on = ' '): void
|
||||||
{
|
{
|
||||||
$this->taskExec(implode($join_on, $cmd_parts))->run();
|
$this->taskExec(implode($join_on, $cmd_parts))->run();
|
||||||
}
|
}
|
||||||
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -44,10 +44,13 @@ return static function ($configArray = []) {
|
|||||||
|
|
||||||
$appLogger = new Logger('animeclient');
|
$appLogger = new Logger('animeclient');
|
||||||
$appLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', Logger::NOTICE));
|
$appLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', Logger::NOTICE));
|
||||||
|
|
||||||
$anilistRequestLogger = new Logger('anilist-request');
|
$anilistRequestLogger = new Logger('anilist-request');
|
||||||
$anilistRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/anilist_request.log', Logger::NOTICE));
|
$anilistRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/anilist_request.log', Logger::NOTICE));
|
||||||
|
|
||||||
$kitsuRequestLogger = new Logger('kitsu-request');
|
$kitsuRequestLogger = new Logger('kitsu-request');
|
||||||
$kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE));
|
$kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE));
|
||||||
|
|
||||||
$container->setLogger($appLogger);
|
$container->setLogger($appLogger);
|
||||||
$container->setLogger($anilistRequestLogger, 'anilist-request');
|
$container->setLogger($anilistRequestLogger, 'anilist-request');
|
||||||
$container->setLogger($kitsuRequestLogger, 'kitsu-request');
|
$container->setLogger($kitsuRequestLogger, 'kitsu-request');
|
||||||
@ -62,7 +65,7 @@ return static function ($configArray = []) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create Cache Object
|
// Create Cache Object
|
||||||
$container->set('cache', static function($container) {
|
$container->set('cache', static function($container): Pool {
|
||||||
$logger = $container->getLogger();
|
$logger = $container->getLogger();
|
||||||
$config = $container->get('config')->get('cache');
|
$config = $container->get('config')->get('cache');
|
||||||
return new Pool($config, $logger);
|
return new Pool($config, $logger);
|
||||||
@ -117,12 +120,12 @@ return static function ($configArray = []) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Miscellaneous helper methods
|
// Miscellaneous helper methods
|
||||||
$container->set('util', static function($container) {
|
$container->set('util', static function($container): Util {
|
||||||
return new Util($container);
|
return new Util($container);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
$container->set('kitsu-model', static function($container) {
|
$container->set('kitsu-model', static function($container): Kitsu\Model {
|
||||||
$requestBuilder = new KitsuRequestBuilder();
|
$requestBuilder = new KitsuRequestBuilder();
|
||||||
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
||||||
|
|
||||||
@ -138,7 +141,7 @@ return static function ($configArray = []) {
|
|||||||
$model->setCache($cache);
|
$model->setCache($cache);
|
||||||
return $model;
|
return $model;
|
||||||
});
|
});
|
||||||
$container->set('anilist-model', static function($container) {
|
$container->set('anilist-model', static function($container): Anilist\Model {
|
||||||
$requestBuilder = new Anilist\AnilistRequestBuilder();
|
$requestBuilder = new Anilist\AnilistRequestBuilder();
|
||||||
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
||||||
|
|
||||||
@ -153,9 +156,6 @@ return static function ($configArray = []) {
|
|||||||
return $model;
|
return $model;
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->set('api-model', static function($container) {
|
|
||||||
return new Model\API($container);
|
|
||||||
});
|
|
||||||
$container->set('anime-model', static function($container) {
|
$container->set('anime-model', static function($container) {
|
||||||
return new Model\Anime($container);
|
return new Model\Anime($container);
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<?= $helper->picture("images/anime/{$item['anime']['id']}.webp") ?>
|
<?= $helper->picture("images/anime/{$item['anime']['id']}.webp") ?>
|
||||||
|
|
||||||
<div class="name">
|
<div class="name">
|
||||||
<a href="<?= $url->generate('anime.details', ['id' => $item['anime']['slug']]); ?>">
|
<a href="<?= $url->generate('anime.details', ['id' => $item['anime']['slug']]) ?>">
|
||||||
<span class="canonical"><?= $item['anime']['title'] ?></span>
|
<span class="canonical"><?= $item['anime']['title'] ?></span>
|
||||||
<?php foreach ($item['anime']['titles'] as $title): ?>
|
<?php foreach ($item['anime']['titles'] as $title): ?>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
$setupErrors = \Aviat\AnimeClient\checkFolderPermissions($container->get('config'));
|
|
||||||
|
use function Aviat\AnimeClient\checkFolderPermissions;
|
||||||
|
|
||||||
|
$setupErrors = checkFolderPermissions($container->get('config'));
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ( ! empty($setupErrors)): ?>
|
<?php if ( ! empty($setupErrors)): ?>
|
||||||
|
@ -93,12 +93,12 @@ class InlineCommentSniff implements Sniff
|
|||||||
private function _checkCommentStyle(File $phpcsFile, $stackPtr)
|
private function _checkCommentStyle(File $phpcsFile, $stackPtr)
|
||||||
{
|
{
|
||||||
$tokens = $phpcsFile->getTokens();
|
$tokens = $phpcsFile->getTokens();
|
||||||
if ($tokens[$stackPtr]['content']{0} === '#') {
|
if ($tokens[$stackPtr]['content'][0] === '#') {
|
||||||
$error = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
|
$error = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
|
||||||
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
|
} else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
|
||||||
|| $tokens[$stackPtr]['content']{0} === '*'
|
|| $tokens[$stackPtr]['content'][0] === '*'
|
||||||
) {
|
) {
|
||||||
$error = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
|
$error = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
|
||||||
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* CodeIgniter_Sniffs_Operators_LogicalOperatorAndSniff.
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category PHP
|
|
||||||
* @package PHP_CodeSniffer
|
|
||||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
|
||||||
* @copyright 2006 Thomas Ernest
|
|
||||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
|
||||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CodeIgniter_Sniffs_Operators_LogicalOperatorAndSniff.
|
|
||||||
*
|
|
||||||
* Ensures that the logical operator 'AND' is in upper case and suggest the use of its symbolic equivalent.
|
|
||||||
*
|
|
||||||
* @category PHP
|
|
||||||
* @package PHP_CodeSniffer
|
|
||||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
|
||||||
* @copyright 2006 Thomas Ernest
|
|
||||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
|
||||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace CodeIgniter\Sniffs\Operators;
|
|
||||||
|
|
||||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
|
||||||
use PHP_CodeSniffer\Files\File;
|
|
||||||
|
|
||||||
class LogicalOperatorAndSniff implements Sniff
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns an array of tokens this test wants to listen for: symbolic and literal operators and.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function register()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
T_LOGICAL_AND,
|
|
||||||
);
|
|
||||||
|
|
||||||
}//end register()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes this test, when one of its tokens is encountered.
|
|
||||||
*
|
|
||||||
* @param File $phpcsFile The current file being scanned.
|
|
||||||
* @param int $stackPtr The position of the current token
|
|
||||||
* in the stack passed in $tokens.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function process(File $phpcsFile, $stackPtr)
|
|
||||||
{
|
|
||||||
$tokens = $phpcsFile->getTokens();
|
|
||||||
|
|
||||||
$operator_token = $tokens[$stackPtr];
|
|
||||||
$operator_string = $operator_token['content'];
|
|
||||||
$operator_code = $operator_token['code'];
|
|
||||||
|
|
||||||
if ($operator_string !== strtoupper($operator_string)) {
|
|
||||||
$error_message = 'Logical operator should be in upper case;'
|
|
||||||
. ' use "' . strtoupper($operator_string)
|
|
||||||
. '" instead of "' . $operator_string . '"';
|
|
||||||
$phpcsFile->addError($error_message, $stackPtr, 'LowercaseLogicalOperator');
|
|
||||||
}
|
|
||||||
|
|
||||||
$warning_message = 'The symbolic form "&&" is preferred over the literal form "AND"';
|
|
||||||
$phpcsFile->addWarning($warning_message, $stackPtr, 'UseOfLiteralAndOperator');
|
|
||||||
|
|
||||||
}//end process()
|
|
||||||
|
|
||||||
|
|
||||||
}//end class
|
|
||||||
|
|
||||||
?>
|
|
@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* CodeIgniter_Sniffs_Operators_UppercaseLogicalOperatorOrSniff.
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* @category PHP
|
|
||||||
* @package PHP_CodeSniffer
|
|
||||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
|
||||||
* @copyright 2006 Thomas Ernest
|
|
||||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
|
||||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CodeIgniter_Sniffs_Operators_UppercaseLogicalOperatorOrSniff.
|
|
||||||
*
|
|
||||||
* Ensures that the logical operator 'OR' is in upper cases and its symbolic equivalent.
|
|
||||||
*
|
|
||||||
* @category PHP
|
|
||||||
* @package PHP_CodeSniffer
|
|
||||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
|
||||||
* @copyright 2006 Thomas Ernest
|
|
||||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
|
||||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace CodeIgniter\Sniffs\Operators;
|
|
||||||
|
|
||||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
|
||||||
use PHP_CodeSniffer\Files\File;
|
|
||||||
|
|
||||||
class UppercaseLogicalOperatorOrSniff implements Sniff
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns an array of tokens this test wants to listen for: literal and symbolic operators or.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function register()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
T_BOOLEAN_OR,
|
|
||||||
T_LOGICAL_OR,
|
|
||||||
);
|
|
||||||
|
|
||||||
}//end register()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes this test, when one of its tokens is encountered.
|
|
||||||
*
|
|
||||||
* @param File $phpcsFile The current file being scanned.
|
|
||||||
* @param int $stackPtr The position of the current token
|
|
||||||
* in the stack passed in $tokens.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function process(File $phpcsFile, $stackPtr)
|
|
||||||
{
|
|
||||||
$tokens = $phpcsFile->getTokens();
|
|
||||||
|
|
||||||
$operator_token = $tokens[$stackPtr];
|
|
||||||
$operator_string = $operator_token['content'];
|
|
||||||
$operator_code = $operator_token['code'];
|
|
||||||
|
|
||||||
if ($operator_code == T_BOOLEAN_OR) {
|
|
||||||
$error_message = 'Logical operator "' . $operator_string
|
|
||||||
. '" is prohibited; use "OR" instead';
|
|
||||||
$phpcsFile->addError($error_message, $stackPtr, 'UseOf||InsteadOfOR');
|
|
||||||
}
|
|
||||||
// it is literal, if it is not symbolic
|
|
||||||
else if ($operator_string !== strtoupper($operator_string)) {
|
|
||||||
$error_message = 'Logical operator should be in upper case;'
|
|
||||||
. ' use "' . strtoupper($operator_string)
|
|
||||||
. '" instead of "' . $operator_string . '"';
|
|
||||||
$phpcsFile->addError($error_message, $stackPtr, 'UseOfLowercaseOr');
|
|
||||||
}
|
|
||||||
}//end process()
|
|
||||||
|
|
||||||
|
|
||||||
}//end class
|
|
||||||
|
|
||||||
?>
|
|
@ -23,7 +23,7 @@
|
|||||||
<!-- Classes and functions should be commented -->
|
<!-- Classes and functions should be commented -->
|
||||||
<rule ref="PEAR.Commenting.ClassComment"/>
|
<rule ref="PEAR.Commenting.ClassComment"/>
|
||||||
<rule ref="PEAR.Commenting.FunctionComment"/>
|
<rule ref="PEAR.Commenting.FunctionComment"/>
|
||||||
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>
|
<!-- <rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>-->
|
||||||
<!-- Use warnings for docblock comments for files and variables, since nothing is cleary explained -->
|
<!-- Use warnings for docblock comments for files and variables, since nothing is cleary explained -->
|
||||||
<rule ref="PEAR.Commenting.FileComment">
|
<rule ref="PEAR.Commenting.FileComment">
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# We need to install dependencies only for Docker
|
|
||||||
[[ ! -e /.dockerenv ]] && [[ ! -e /.dockerinit ]] && exit 0
|
|
||||||
|
|
||||||
set -xe
|
|
||||||
|
|
||||||
# Install git (the php image doesn't have it) which is required by composer
|
|
||||||
# echo -e 'http://dl-cdn.alpinelinux.org/alpine/edge/main\nhttp://dl-cdn.alpinelinux.org/alpine/edge/community\nhttp://dl-cdn.alpinelinux.org/alpine/edge/testing' > /etc/apk/repositories
|
|
||||||
apk --update add --no-cache \
|
|
||||||
curl \
|
|
||||||
git
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -18,9 +18,6 @@
|
|||||||
<logging>
|
<logging>
|
||||||
<log type="coverage-html" target="../coverage"/>
|
<log type="coverage-html" target="../coverage"/>
|
||||||
<log type="coverage-clover" target="logs/clover.xml"/>
|
<log type="coverage-clover" target="logs/clover.xml"/>
|
||||||
<log type="coverage-crap4j" target="logs/crap4j.xml"/>
|
|
||||||
<log type="coverage-xml" target="logs/coverage" />
|
|
||||||
<log type="junit" target="logs/junit.xml" />
|
|
||||||
</logging>
|
</logging>
|
||||||
<php>
|
<php>
|
||||||
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0" />
|
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0" />
|
||||||
|
@ -29,13 +29,13 @@ if ( ! function_exists('glob_recursive'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_text_to_replace($tokens)
|
function get_text_to_replace(array $tokens): string
|
||||||
{
|
{
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
// Tokens have the follow structure if arrays:
|
// Tokens have the follow structure if arrays:
|
||||||
// [0] => token type constant
|
// [0] => token type constant
|
||||||
// [1] => raw sytax parsed to that token
|
// [1] => raw syntax parsed to that token
|
||||||
// [2] => line number
|
// [2] => line number
|
||||||
foreach($tokens as $token)
|
foreach($tokens as $token)
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ function get_text_to_replace($tokens)
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_tokens($source)
|
function get_tokens($source): array
|
||||||
{
|
{
|
||||||
return token_get_all($source);
|
return token_get_all($source);
|
||||||
}
|
}
|
||||||
|
@ -2,54 +2,74 @@
|
|||||||
"name": "aviat/hummingbird-anime-client",
|
"name": "aviat/hummingbird-anime-client",
|
||||||
"description": "A self-hosted anime/manga client for Kitsu.",
|
"description": "A self-hosted anime/manga client for Kitsu.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Timothy J. Warren",
|
||||||
|
"email": "tim@timshomepage.net",
|
||||||
|
"homepage": "https://timshomepage.net",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": [
|
"files": [
|
||||||
"src/constants.php",
|
"src/Ion/functions.php",
|
||||||
"src/AnimeClient.php"
|
"src/AnimeClient/constants.php",
|
||||||
|
"src/AnimeClient/AnimeClient.php"
|
||||||
],
|
],
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Aviat\\AnimeClient\\": "src/"
|
"Aviat\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Aviat\\AnimeClient\\Tests\\": "tests/",
|
"Aviat\\AnimeClient\\Tests\\": "tests/AnimeClient",
|
||||||
|
"Aviat\\Ion\\Tests\\": "tests/Ion",
|
||||||
"CodeIgniter\\": "build/CodeIgniter/"
|
"CodeIgniter\\": "build/CodeIgniter/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"config": {
|
||||||
|
"lock": false,
|
||||||
|
"platform": {
|
||||||
|
"php": "7.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"amphp/artax": "^3.0",
|
"amphp/http-client": "^4.2",
|
||||||
"aura/html": "^2.0",
|
"aura/html": "^2.0",
|
||||||
"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/ion": "^2.4.1",
|
"aviat/query": "^2.5.1",
|
||||||
|
"danielstjules/stringy": "^3.1.0",
|
||||||
|
"ext-dom": "*",
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-gd":"*",
|
"ext-gd": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
|
"laminas/laminas-diactoros": "^2.0.0",
|
||||||
|
"laminas/laminas-httphandlerrunner": "^1.0",
|
||||||
"maximebf/consolekit": "^1.0",
|
"maximebf/consolekit": "^1.0",
|
||||||
"monolog/monolog": "^1.0",
|
"monolog/monolog": "^2.0.1",
|
||||||
|
"php": "^7.3",
|
||||||
|
"psr/container": "~1.0",
|
||||||
"psr/http-message": "~1.0",
|
"psr/http-message": "~1.0",
|
||||||
"psr/log": "~1.0",
|
"psr/log": "~1.0",
|
||||||
"yosymfony/toml": "^1.0",
|
"yosymfony/toml": "^1.0"
|
||||||
"zendframework/zend-diactoros": "^2.0.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"consolidation/robo": "~1.0",
|
"consolidation/robo": "^2.0.0",
|
||||||
"filp/whoops": "^2.1",
|
"filp/whoops": "^2.1",
|
||||||
"henrikbjorn/lurker": "^1.1.0",
|
|
||||||
"pdepend/pdepend": "^2.2",
|
"pdepend/pdepend": "^2.2",
|
||||||
"phploc/phploc": "^4.0",
|
"phploc/phploc": "^5.0",
|
||||||
"phpmd/phpmd": "^2.4",
|
"phpmd/phpmd": "^2.8",
|
||||||
"phpstan/phpstan": "^0.10.5",
|
"phpstan/phpstan": "^0.12.0",
|
||||||
"phpunit/phpunit": "^7.4.3",
|
"phpunit/phpunit": "^8.4.3",
|
||||||
"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": "^4.1.0",
|
||||||
"spatie/phpunit-snapshot-assertions": "^1.2.0",
|
"spatie/phpunit-snapshot-assertions": "^2.2.1",
|
||||||
"squizlabs/php_codesniffer": "^3.2.2",
|
"squizlabs/php_codesniffer": "^3.2.2",
|
||||||
"symfony/var-dumper": "^4.0.1",
|
"symfony/var-dumper": "^5",
|
||||||
"theseer/phpdox": "*"
|
"theseer/phpdox": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -58,10 +78,11 @@
|
|||||||
"build:js": "cd public && npm run build:js && cd ..",
|
"build:js": "cd public && npm run build:js && cd ..",
|
||||||
"clean": "vendor/bin/robo clean",
|
"clean": "vendor/bin/robo clean",
|
||||||
"coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build",
|
"coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build",
|
||||||
"phpstan": "phpstan analyse -l 4 -c phpstan.neon src tests ./console index.php",
|
"phpstan": "phpstan analyse -c phpstan.neon",
|
||||||
"watch:css": "cd public && npm run watch:css",
|
"watch:css": "cd public && npm run watch:css",
|
||||||
"watch:js": "cd public && npm run watch:js",
|
"watch:js": "cd public && npm run watch:js",
|
||||||
"test": "vendor/bin/phpunit"
|
"test": "vendor/bin/phpunit -c build --no-coverage",
|
||||||
|
"test-update": "vendor/bin/phpunit -c build --no-coverage -d --update-snapshots"
|
||||||
},
|
},
|
||||||
"scripts-descriptions": {
|
"scripts-descriptions": {
|
||||||
"build": "Generate the api docs",
|
"build": "Generate the api docs",
|
||||||
|
12
index.php
12
index.php
@ -4,19 +4,21 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient;
|
namespace Aviat\AnimeClient;
|
||||||
|
|
||||||
use Aviat\AnimeClient\Types\Config as ConfigType;
|
use Aviat\AnimeClient\Types\Config as ConfigType;
|
||||||
|
use Whoops\Handler\PrettyPageHandler;
|
||||||
|
use Whoops\Run;
|
||||||
|
|
||||||
use function Aviat\Ion\_dir;
|
use function Aviat\Ion\_dir;
|
||||||
|
|
||||||
@ -34,8 +36,8 @@ require_once __DIR__ . '/vendor/autoload.php';
|
|||||||
|
|
||||||
// if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development')
|
// if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development')
|
||||||
{
|
{
|
||||||
$whoops = new \Whoops\Run;
|
$whoops = new Run;
|
||||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
|
$whoops->pushHandler(new PrettyPageHandler);
|
||||||
$whoops->register();
|
$whoops->register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
phpdox.xml
18
phpdox.xml
@ -78,10 +78,10 @@
|
|||||||
</source>
|
</source>
|
||||||
|
|
||||||
<!-- git vcs information -->
|
<!-- git vcs information -->
|
||||||
<source type="git">
|
<!-- <source type="git">
|
||||||
<git binary="/usr/bin/git" />
|
<git binary="/usr/bin/git" />
|
||||||
<history enabled="true" limit="15" cache="${phpDox.project.workdir}/gitlog.xml" />
|
<history enabled="true" limit="15" cache="${phpDox.project.workdir}/gitlog.xml" />
|
||||||
</source>
|
</source> -->
|
||||||
|
|
||||||
<!-- PHP Code Sniffer findings -->
|
<!-- PHP Code Sniffer findings -->
|
||||||
<source type="checkstyle">
|
<source type="checkstyle">
|
||||||
@ -89,24 +89,18 @@
|
|||||||
</source>
|
</source>
|
||||||
|
|
||||||
<!-- PHPMessDetector -->
|
<!-- PHPMessDetector -->
|
||||||
<!--
|
|
||||||
<source type="pmd">
|
<source type="pmd">
|
||||||
<file name="pmd.xml" />
|
<file name="phpmd.xml" />
|
||||||
</source>
|
</source>
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- PHPUnit Coverage XML -->
|
<!-- PHPUnit Coverage XML -->
|
||||||
<source type="phpunit">
|
<!-- <source type="phpunit"> -->
|
||||||
<coverage path="coverage/clover.xml" />
|
<!-- <coverage path="coverage" /> -->
|
||||||
<!-- <coverage path="clover.xml" />-->
|
<!-- <coverage path="clover.xml" />-->
|
||||||
<!-- @path - the directory where the xml code coverage report can be found -->
|
<!-- @path - the directory where the xml code coverage report can be found -->
|
||||||
<!--<filter directory="${phpDox.project.source}" />-->
|
<!--<filter directory="${phpDox.project.source}" />-->
|
||||||
<!-- @directory - path of the phpunit config whitelist filter directory -->
|
<!-- @directory - path of the phpunit config whitelist filter directory -->
|
||||||
</source>
|
<!-- </source> -->
|
||||||
<source type="phpunit">
|
|
||||||
<filter directory="${phpDox.project.source}" />
|
|
||||||
</source>
|
|
||||||
|
|
||||||
</enrich>
|
</enrich>
|
||||||
|
|
||||||
<!-- <build engine="..." enabled="true" output="..." /> -->
|
<!-- <build engine="..." enabled="true" output="..." /> -->
|
||||||
|
11
phpstan.neon
11
phpstan.neon
@ -1,9 +1,18 @@
|
|||||||
parameters:
|
parameters:
|
||||||
|
checkGenericClassInNonGenericObjectType: false
|
||||||
|
checkMissingIterableValueType: false
|
||||||
|
inferPrivatePropertyTypeFromConstructor: true
|
||||||
|
level: 7
|
||||||
autoload_files:
|
autoload_files:
|
||||||
- %rootDir%/../../../tests/mocks.php
|
- %rootDir%/../../../tests/mocks.php
|
||||||
|
paths:
|
||||||
|
- src
|
||||||
|
- ./console
|
||||||
|
- index.php
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- '#Access to an undefined property Aviat\\\Ion\\\Friend::\$[a-zA-Z0-9_]+#'
|
- '#Access to an undefined property Aviat\\\Ion\\\Friend::\$[a-zA-Z0-9_]+#'
|
||||||
- '#Call to an undefined method Aviat\\\Ion\\\Friend::[a-zA-Z0-9_]+\(\)#'
|
- '#Call to an undefined method Aviat\\\Ion\\\Friend::[a-zA-Z0-9_]+\(\)#'
|
||||||
- '#Call to an undefined method Aura\\\Html\\\HelperLocator::[a-zA-Z0-9_]+\(\)#'
|
- '#Call to an undefined method Aura\\\Html\\\HelperLocator::[a-zA-Z0-9_]+\(\)#'
|
||||||
- '#Undefined variable: \$var#'
|
|
||||||
- '#Property Amp\\Artax\\Internal\\RequestCycle::\$[a-zA-Z0-9_]+#'
|
- '#Property Amp\\Artax\\Internal\\RequestCycle::\$[a-zA-Z0-9_]+#'
|
||||||
|
excludes_analyse:
|
||||||
|
- tests/mocks.php
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -22,15 +22,16 @@ use function Amp\Promise\wait;
|
|||||||
use function Aviat\AnimeClient\getResponse;
|
use function Aviat\AnimeClient\getResponse;
|
||||||
|
|
||||||
use Amp;
|
use Amp;
|
||||||
use Amp\Artax\{FormBody, Request};
|
use Amp\Http\Client\Request;
|
||||||
|
use Amp\Http\Client\Body\FormBody;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Psr\Log\LoggerAwareTrait;
|
use Psr\Log\LoggerAwareTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around Artax to make it easier to build API requests
|
* Wrapper around Http\Client to make it easier to build API requests
|
||||||
*/
|
*/
|
||||||
class APIRequestBuilder {
|
abstract class APIRequestBuilder {
|
||||||
use LoggerAwareTrait;
|
use LoggerAwareTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +66,7 @@ class APIRequestBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The current request
|
* The current request
|
||||||
* @var \Amp\Artax\Request
|
* @var Request
|
||||||
*/
|
*/
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ class APIRequestBuilder {
|
|||||||
public static function simpleRequest(string $uri): Request
|
public static function simpleRequest(string $uri): Request
|
||||||
{
|
{
|
||||||
return (new Request($uri))
|
return (new Request($uri))
|
||||||
->withHeader('User-Agent', USER_AGENT);
|
->setHeader('User-Agent', USER_AGENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,7 +119,7 @@ class APIRequestBuilder {
|
|||||||
*/
|
*/
|
||||||
public function setBody($body): self
|
public function setBody($body): self
|
||||||
{
|
{
|
||||||
$this->request = $this->request->withBody($body);
|
$this->request->setBody($body);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ class APIRequestBuilder {
|
|||||||
*/
|
*/
|
||||||
public function unsetHeader(string $name): self
|
public function unsetHeader(string $name): self
|
||||||
{
|
{
|
||||||
$this->request = $this->request->withoutHeader($name);
|
$this->request->removeHeader($name);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ class APIRequestBuilder {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->request = $this->request->withHeader($name, $value);
|
$this->request->setHeader($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -219,14 +220,14 @@ class APIRequestBuilder {
|
|||||||
/**
|
/**
|
||||||
* Return the promise for the current request
|
* Return the promise for the current request
|
||||||
*
|
*
|
||||||
|
* @return Request
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
* @return \Amp\Artax\Request
|
|
||||||
*/
|
*/
|
||||||
public function getFullRequest(): Request
|
public function getFullRequest(): Request
|
||||||
{
|
{
|
||||||
$this->buildUri();
|
$this->buildUri();
|
||||||
|
|
||||||
if ($this->logger)
|
if ($this->logger !== NULL)
|
||||||
{
|
{
|
||||||
$this->logger->debug('API Request', [
|
$this->logger->debug('API Request', [
|
||||||
'request_url' => $this->request->getUri(),
|
'request_url' => $this->request->getUri(),
|
||||||
@ -254,7 +255,7 @@ class APIRequestBuilder {
|
|||||||
public function getResponseData(Request $request)
|
public function getResponseData(Request $request)
|
||||||
{
|
{
|
||||||
$response = getResponse($request);
|
$response = getResponse($request);
|
||||||
return wait($response->getBody());
|
return wait($response->getBody()->buffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,7 +307,7 @@ class APIRequestBuilder {
|
|||||||
$url .= '?' . $this->query;
|
$url .= '?' . $this->query;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->request = $this->request->withUri($url);
|
$this->request->setUri($url);
|
||||||
|
|
||||||
return $this->request;
|
return $this->request;
|
||||||
}
|
}
|
||||||
@ -324,7 +325,8 @@ class APIRequestBuilder {
|
|||||||
|
|
||||||
$this->path = '';
|
$this->path = '';
|
||||||
$this->query = '';
|
$this->query = '';
|
||||||
$this->request = (new Request($requestUrl))
|
$this->request = new Request($requestUrl, $type);
|
||||||
->withMethod($type);
|
$this->request->setTcpConnectTimeout(300000);
|
||||||
|
$this->request->setTransferTimeout(300000);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,25 +4,25 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API;
|
namespace Aviat\AnimeClient\API;
|
||||||
|
|
||||||
use Amp\Artax\Request;
|
use Amp\Http\Client\Request;
|
||||||
use Aviat\AnimeClient\Types\FormItemData;
|
use Aviat\AnimeClient\Types\FormItemData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for anime and manga list item CRUD
|
* Common interface for anime and manga list item CRUD
|
||||||
*/
|
*/
|
||||||
interface ListItemInterface {
|
abstract class AbstractListItem {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a list item
|
* Create a list item
|
||||||
@ -30,7 +30,7 @@ interface ListItemInterface {
|
|||||||
* @param array $data -
|
* @param array $data -
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function create(array $data): Request;
|
abstract public function create(array $data): Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list item
|
* Retrieve a list item
|
||||||
@ -38,7 +38,7 @@ interface ListItemInterface {
|
|||||||
* @param string $id - The id of the list item
|
* @param string $id - The id of the list item
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get(string $id): array;
|
abstract public function get(string $id): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increase progress on a list item
|
* Increase progress on a list item
|
||||||
@ -47,7 +47,7 @@ interface ListItemInterface {
|
|||||||
* @param FormItemData $data
|
* @param FormItemData $data
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function increment(string $id, FormItemData $data): Request;
|
abstract public function increment(string $id, FormItemData $data): Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a list item
|
* Update a list item
|
||||||
@ -56,7 +56,7 @@ interface ListItemInterface {
|
|||||||
* @param FormItemData $data - The data with which to update the list item
|
* @param FormItemData $data - The data with which to update the list item
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function update(string $id, FormItemData $data): Request;
|
abstract public function update(string $id, FormItemData $data): Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a list item
|
* Delete a list item
|
||||||
@ -64,5 +64,5 @@ interface ListItemInterface {
|
|||||||
* @param string $id - The id of the list item to delete
|
* @param string $id - The id of the list item to delete
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function delete(string $id): Request;
|
abstract public function delete(string $id):?Request;
|
||||||
}
|
}
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -21,13 +21,16 @@ use const Aviat\AnimeClient\USER_AGENT;
|
|||||||
use function Amp\Promise\wait;
|
use function Amp\Promise\wait;
|
||||||
use function Aviat\AnimeClient\getResponse;
|
use function Aviat\AnimeClient\getResponse;
|
||||||
|
|
||||||
use Amp\Artax\Request;
|
use Amp\Http\Client\Request;
|
||||||
use Amp\Artax\Response;
|
use Amp\Http\Client\Response;
|
||||||
|
|
||||||
use Aviat\AnimeClient\API\Anilist;
|
use Aviat\AnimeClient\API\Anilist;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use Aviat\Ion\Di\ContainerAware;
|
use Aviat\Ion\Di\ContainerAware;
|
||||||
|
|
||||||
|
use LogicException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
trait AnilistTrait {
|
trait AnilistTrait {
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
|
|
||||||
@ -69,10 +72,10 @@ trait AnilistTrait {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a request object
|
* Create a request object
|
||||||
|
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return Request
|
* @return Request
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function setUpRequest(string $url, array $options = []): Request
|
public function setUpRequest(string $url, array $options = []): Request
|
||||||
{
|
{
|
||||||
@ -123,7 +126,7 @@ trait AnilistTrait {
|
|||||||
$file = realpath(__DIR__ . "/GraphQL/Queries/{$name}.graphql");
|
$file = realpath(__DIR__ . "/GraphQL/Queries/{$name}.graphql");
|
||||||
if ( ! file_exists($file))
|
if ( ! file_exists($file))
|
||||||
{
|
{
|
||||||
throw new \LogicException('GraphQL query file does not exist.');
|
throw new LogicException('GraphQL query file does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
|
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
|
||||||
@ -146,12 +149,18 @@ trait AnilistTrait {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param array $variables
|
||||||
|
* @return Request
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function mutateRequest (string $name, array $variables = []): Request
|
public function mutateRequest (string $name, array $variables = []): Request
|
||||||
{
|
{
|
||||||
$file = realpath(__DIR__ . "/GraphQL/Mutations/{$name}.graphql");
|
$file = realpath(__DIR__ . "/GraphQL/Mutations/{$name}.graphql");
|
||||||
if (!file_exists($file))
|
if (!file_exists($file))
|
||||||
{
|
{
|
||||||
throw new \LogicException('GraphQL mutation file does not exist.');
|
throw new LogicException('GraphQL mutation file does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
|
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
|
||||||
@ -174,12 +183,18 @@ trait AnilistTrait {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param array $variables
|
||||||
|
* @return array
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function mutate (string $name, array $variables = []): array
|
public function mutate (string $name, array $variables = []): array
|
||||||
{
|
{
|
||||||
$request = $this->mutateRequest($name, $variables);
|
$request = $this->mutateRequest($name, $variables);
|
||||||
$response = $this->getResponseFromRequest($request);
|
$response = $this->getResponseFromRequest($request);
|
||||||
|
|
||||||
return Json::decode(wait($response->getBody()));
|
return Json::decode(wait($response->getBody()->buffer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,6 +203,7 @@ trait AnilistTrait {
|
|||||||
* @param string $url
|
* @param string $url
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return Response
|
* @return Response
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
private function getResponse(string $url, array $options = []): Response
|
private function getResponse(string $url, array $options = []): Response
|
||||||
{
|
{
|
||||||
@ -211,6 +227,11 @@ trait AnilistTrait {
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
private function getResponseFromRequest(Request $request): Response
|
private function getResponseFromRequest(Request $request): Response
|
||||||
{
|
{
|
||||||
$logger = NULL;
|
$logger = NULL;
|
||||||
@ -237,6 +258,7 @@ trait AnilistTrait {
|
|||||||
*
|
*
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
protected function postRequest(array $options = []): array
|
protected function postRequest(array $options = []): array
|
||||||
{
|
{
|
||||||
@ -258,14 +280,14 @@ trait AnilistTrait {
|
|||||||
|
|
||||||
if ( ! \in_array($response->getStatus(), $validResponseCodes, TRUE))
|
if ( ! \in_array($response->getStatus(), $validResponseCodes, TRUE))
|
||||||
{
|
{
|
||||||
if ($logger)
|
if ($logger !== NULL)
|
||||||
{
|
{
|
||||||
$logger->warning('Non 200 response for POST api call', (array)$response->getBody());
|
$logger->warning('Non 200 response for POST api call', (array)$response->getBody());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump(wait($response->getBody()));
|
// dump(wait($response->getBody()->buffer()));
|
||||||
|
|
||||||
return Json::decode(wait($response->getBody()));
|
return Json::decode(wait($response->getBody()->buffer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,21 +4,21 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Anilist;
|
namespace Aviat\AnimeClient\API\Anilist;
|
||||||
|
|
||||||
use Amp\Artax\Request;
|
use Amp\Http\Client\Request;
|
||||||
|
|
||||||
use Aviat\AnimeClient\API\ListItemInterface;
|
use Aviat\AnimeClient\API\AbstractListItem;
|
||||||
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Anilist as AnilistStatus;
|
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Anilist as AnilistStatus;
|
||||||
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
|
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
|
||||||
use Aviat\AnimeClient\Types\FormItemData;
|
use Aviat\AnimeClient\Types\FormItemData;
|
||||||
@ -26,7 +26,7 @@ use Aviat\AnimeClient\Types\FormItemData;
|
|||||||
/**
|
/**
|
||||||
* CRUD operations for MAL list items
|
* CRUD operations for MAL list items
|
||||||
*/
|
*/
|
||||||
final class ListItem implements ListItemInterface{
|
final class ListItem extends AbstractListItem {
|
||||||
use AnilistTrait;
|
use AnilistTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +37,8 @@ final class ListItem implements ListItemInterface{
|
|||||||
*/
|
*/
|
||||||
public function create(array $data): Request
|
public function create(array $data): Request
|
||||||
{
|
{
|
||||||
return $this->mutateRequest('CreateMediaListEntry', $data);
|
$checkedData = (new Types\MediaListEntry($data))->toArray();
|
||||||
|
return $this->mutateRequest('CreateMediaListEntry', $checkedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +49,8 @@ final class ListItem implements ListItemInterface{
|
|||||||
*/
|
*/
|
||||||
public function createFull(array $data): Request
|
public function createFull(array $data): Request
|
||||||
{
|
{
|
||||||
return $this->mutateRequest('CreateFullMediaListEntry', $data);
|
$checkedData = (new Types\MediaListEntry($data))->toArray();
|
||||||
|
return $this->mutateRequest('CreateFullMediaListEntry', $checkedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,10 +85,12 @@ final class ListItem implements ListItemInterface{
|
|||||||
*/
|
*/
|
||||||
public function increment(string $id, FormItemData $data): Request
|
public function increment(string $id, FormItemData $data): Request
|
||||||
{
|
{
|
||||||
return $this->mutateRequest('IncrementMediaListEntry', [
|
$checkedData = (new Types\MediaListEntry([
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'progress' => $data['progress'],
|
'progress' => $data->progress,
|
||||||
]);
|
]))->toArray();
|
||||||
|
|
||||||
|
return $this->mutateRequest('IncrementMediaListEntry', $checkedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,15 +102,15 @@ final class ListItem implements ListItemInterface{
|
|||||||
*/
|
*/
|
||||||
public function update(string $id, FormItemData $data): Request
|
public function update(string $id, FormItemData $data): Request
|
||||||
{
|
{
|
||||||
$array = $data->toArray();
|
$notes = $data->notes ?? '';
|
||||||
|
$progress = (int)$data->progress;
|
||||||
|
$private = (bool)$data->private;
|
||||||
|
$rating = $data->ratingTwenty;
|
||||||
|
$status = ($data->reconsuming === TRUE)
|
||||||
|
? AnilistStatus::REPEATING
|
||||||
|
: AnimeWatchingStatus::KITSU_TO_ANILIST[$data->status];
|
||||||
|
|
||||||
$notes = $data['notes'] ?? '';
|
$updateData = (new Types\MediaListEntry([
|
||||||
$progress = array_key_exists('progress', $array) ? $data['progress'] : 0;
|
|
||||||
$private = array_key_exists('private', $array) ? (bool)$data['private'] : false;
|
|
||||||
$rating = array_key_exists('ratingTwenty', $array) ? $data['ratingTwenty'] : NULL;
|
|
||||||
$status = ($data['reconsuming'] === true) ? AnilistStatus::REPEATING : AnimeWatchingStatus::KITSU_TO_ANILIST[$data['status']];
|
|
||||||
|
|
||||||
$updateData = [
|
|
||||||
'id' => (int)$id,
|
'id' => (int)$id,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'score' => $rating * 5,
|
'score' => $rating * 5,
|
||||||
@ -114,7 +118,7 @@ final class ListItem implements ListItemInterface{
|
|||||||
'repeat' => (int)$data['reconsumeCount'],
|
'repeat' => (int)$data['reconsumeCount'],
|
||||||
'private' => $private,
|
'private' => $private,
|
||||||
'notes' => $notes,
|
'notes' => $notes,
|
||||||
];
|
]))->toArray();
|
||||||
|
|
||||||
return $this->mutateRequest('UpdateMediaListEntry', $updateData);
|
return $this->mutateRequest('UpdateMediaListEntry', $updateData);
|
||||||
}
|
}
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -20,11 +20,15 @@ use function Amp\Promise\wait;
|
|||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
use Amp\Artax\Request;
|
use Amp\Http\Client\Request;
|
||||||
use Aviat\AnimeClient\API\Anilist;
|
use Aviat\AnimeClient\API\Anilist;
|
||||||
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
|
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
|
||||||
use Aviat\AnimeClient\Types\FormItem;
|
use Aviat\AnimeClient\Types\FormItem;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anilist API Model
|
* Anilist API Model
|
||||||
@ -57,6 +61,7 @@ final class Model
|
|||||||
* @param string $code - The request token
|
* @param string $code - The request token
|
||||||
* @param string $redirectUri - The oauth callback url
|
* @param string $redirectUri - The oauth callback url
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function authenticate(string $code, string $redirectUri): array
|
public function authenticate(string $code, string $redirectUri): array
|
||||||
{
|
{
|
||||||
@ -74,7 +79,7 @@ final class Model
|
|||||||
|
|
||||||
$response = $this->getResponseFromRequest($request);
|
$response = $this->getResponseFromRequest($request);
|
||||||
|
|
||||||
return Json::decode(wait($response->getBody()));
|
return Json::decode(wait($response->getBody()->buffer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,8 +97,8 @@ final class Model
|
|||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function getSyncList(string $type = 'anime'): array
|
public function getSyncList(string $type = 'anime'): array
|
||||||
{
|
{
|
||||||
@ -118,16 +123,21 @@ final class Model
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function createListItem(array $data, string $type = 'anime'): Request
|
public function createListItem(array $data, string $type = 'anime'): ?Request
|
||||||
{
|
{
|
||||||
$createData = [];
|
if ($data['mal_id'] === NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
$mediaId = $this->getMediaIdFromMalId($data['mal_id'], mb_strtoupper($type));
|
$mediaId = $this->getMediaIdFromMalId($data['mal_id'], mb_strtoupper($type));
|
||||||
|
|
||||||
/* if (empty($mediaId))
|
if ($mediaId === NULL)
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException('Media id missing');
|
return NULL;
|
||||||
} */
|
}
|
||||||
|
|
||||||
|
$createData = [];
|
||||||
|
|
||||||
if ($type === 'ANIME')
|
if ($type === 'ANIME')
|
||||||
{
|
{
|
||||||
@ -144,7 +154,7 @@ final class Model
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->listItem->create($createData, $type);
|
return $this->listItem->create($createData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,7 +184,8 @@ final class Model
|
|||||||
*
|
*
|
||||||
* @param string $malId - The unique identifier of that list item
|
* @param string $malId - The unique identifier of that list item
|
||||||
* @param string $type - Them media type (anime/manga)
|
* @param string $type - Them media type (anime/manga)
|
||||||
* @return mixed
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getListItem(string $malId, string $type): array
|
public function getListItem(string $malId, string $type): array
|
||||||
{
|
{
|
||||||
@ -194,9 +205,13 @@ final class Model
|
|||||||
* @param string $type - Them media type (anime/manga)
|
* @param string $type - Them media type (anime/manga)
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function incrementListItem(FormItem $data, string $type): Request
|
public function incrementListItem(FormItem $data, string $type): ?Request
|
||||||
{
|
{
|
||||||
$id = $this->getListIdFromMalId($data['mal_id'], $type);
|
$id = $this->getListIdFromMalId($data['mal_id'], $type);
|
||||||
|
if ($id === NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->listItem->increment($id, $data['data']);
|
return $this->listItem->increment($id, $data['data']);
|
||||||
}
|
}
|
||||||
@ -208,10 +223,15 @@ final class Model
|
|||||||
* @param string $type - Them media type (anime/manga)
|
* @param string $type - Them media type (anime/manga)
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function updateListItem(FormItem $data, string $type): Request
|
public function updateListItem(FormItem $data, string $type): ?Request
|
||||||
{
|
{
|
||||||
$id = $this->getListIdFromMalId($data['mal_id'], mb_strtoupper($type));
|
$id = $this->getListIdFromMalId($data['mal_id'], mb_strtoupper($type));
|
||||||
|
|
||||||
|
if ($id === NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->listItem->update($id, $data['data']);
|
return $this->listItem->update($id, $data['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,11 +242,15 @@ final class Model
|
|||||||
* @param string $type - Them media type (anime/manga)
|
* @param string $type - Them media type (anime/manga)
|
||||||
* @return Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function deleteListItem(string $malId, string $type): Request
|
public function deleteListItem(string $malId, string $type): ?Request
|
||||||
{
|
{
|
||||||
$item_id = $this->getListIdFromMalId($malId, $type);
|
$id = $this->getListIdFromMalId($malId, $type);
|
||||||
|
if ($id === NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->listItem->delete($item_id);
|
return $this->listItem->delete($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -239,6 +263,11 @@ final class Model
|
|||||||
public function getListIdFromMalId(string $malId, string $type): ?string
|
public function getListIdFromMalId(string $malId, string $type): ?string
|
||||||
{
|
{
|
||||||
$mediaId = $this->getMediaIdFromMalId($malId, $type);
|
$mediaId = $this->getMediaIdFromMalId($malId, $type);
|
||||||
|
if ($mediaId === NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->getListIdFromMediaId($mediaId);
|
return $this->getListIdFromMediaId($mediaId);
|
||||||
}
|
}
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
56
src/AnimeClient/API/Anilist/Types/MediaListEntry.php
Normal file
56
src/AnimeClient/API/Anilist/Types/MediaListEntry.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* Hummingbird Anime List Client
|
||||||
|
*
|
||||||
|
* An API client for Kitsu to manage anime and manga watch lists
|
||||||
|
*
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @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 4.2
|
||||||
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Aviat\AnimeClient\API\Anilist\Types;
|
||||||
|
|
||||||
|
use Aviat\AnimeClient\Types\AbstractType;
|
||||||
|
|
||||||
|
class MediaListEntry extends AbstractType {
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $notes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $private;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $progress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $repeat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $score;
|
||||||
|
}
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -144,6 +144,8 @@ final class JsonAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset($item);
|
||||||
|
|
||||||
$data['data']['included'] = $included;
|
$data['data']['included'] = $included;
|
||||||
|
|
||||||
return $data['data'];
|
return $data['data'];
|
||||||
@ -193,6 +195,7 @@ final class JsonAPI {
|
|||||||
|
|
||||||
$organized[$type][$id] = $newItem;
|
$organized[$type][$id] = $newItem;
|
||||||
}
|
}
|
||||||
|
unset($item);
|
||||||
|
|
||||||
// Second pass, go through and fill missing relationships in the first pass
|
// Second pass, go through and fill missing relationships in the first pass
|
||||||
foreach($organized as $type => $items)
|
foreach($organized as $type => $items)
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -4,18 +4,21 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Kitsu;
|
namespace Aviat\AnimeClient\API\Kitsu;
|
||||||
|
|
||||||
|
use Aura\Session\Segment;
|
||||||
|
|
||||||
|
use Aviat\Banker\Exception\InvalidArgumentException;
|
||||||
use const Aviat\AnimeClient\SESSION_SEGMENT;
|
use const Aviat\AnimeClient\SESSION_SEGMENT;
|
||||||
|
|
||||||
use Aviat\AnimeClient\API\{
|
use Aviat\AnimeClient\API\{
|
||||||
@ -23,7 +26,9 @@ use Aviat\AnimeClient\API\{
|
|||||||
Kitsu as K
|
Kitsu as K
|
||||||
};
|
};
|
||||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||||
use Exception;
|
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kitsu API Authentication
|
* Kitsu API Authentication
|
||||||
@ -42,7 +47,7 @@ final class Auth {
|
|||||||
/**
|
/**
|
||||||
* Session object
|
* Session object
|
||||||
*
|
*
|
||||||
* @var \Aura\Session\Segment
|
* @var Segment
|
||||||
*/
|
*/
|
||||||
private $segment;
|
private $segment;
|
||||||
|
|
||||||
@ -50,6 +55,8 @@ final class Auth {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
|
* @throws ContainerException
|
||||||
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -66,6 +73,8 @@ final class Auth {
|
|||||||
*
|
*
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function authenticate(string $password): bool
|
public function authenticate(string $password): bool
|
||||||
{
|
{
|
||||||
@ -109,6 +118,8 @@ final class Auth {
|
|||||||
*
|
*
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function reAuthenticate(string $token): bool
|
public function reAuthenticate(string $token): bool
|
||||||
{
|
{
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ use const Aviat\AnimeClient\SESSION_SEGMENT;
|
|||||||
use function Amp\Promise\wait;
|
use function Amp\Promise\wait;
|
||||||
use function Aviat\AnimeClient\getResponse;
|
use function Aviat\AnimeClient\getResponse;
|
||||||
|
|
||||||
use Amp\Artax\Request;
|
use Amp\Http\Client\Request;
|
||||||
use Amp\Artax\Response;
|
use Amp\Http\Client\Response;
|
||||||
use Aviat\AnimeClient\API\{
|
use Aviat\AnimeClient\API\{
|
||||||
FailedResponseException,
|
FailedResponseException,
|
||||||
Kitsu as K
|
Kitsu as K
|
||||||
@ -30,6 +30,8 @@ use Aviat\AnimeClient\API\{
|
|||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use Aviat\Ion\JsonException;
|
use Aviat\Ion\JsonException;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
trait KitsuTrait {
|
trait KitsuTrait {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +58,7 @@ trait KitsuTrait {
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return \Amp\Artax\Request
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public function setUpRequest(string $type, string $url, array $options = []): Request
|
public function setUpRequest(string $type, string $url, array $options = []): Request
|
||||||
{
|
{
|
||||||
@ -120,6 +122,7 @@ trait KitsuTrait {
|
|||||||
* @param string $url
|
* @param string $url
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return Response
|
* @return Response
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
private function getResponse(string $type, string $url, array $options = []): Response
|
private function getResponse(string $type, string $url, array $options = []): Response
|
||||||
{
|
{
|
||||||
@ -151,8 +154,9 @@ trait KitsuTrait {
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @throws \Aviat\Ion\JsonException
|
* @throws JsonException
|
||||||
* @throws FailedResponseException
|
* @throws FailedResponseException
|
||||||
|
* @throws Throwable
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function request(string $type, string $url, array $options = []): array
|
private function request(string $type, string $url, array $options = []): array
|
||||||
@ -165,7 +169,7 @@ trait KitsuTrait {
|
|||||||
|
|
||||||
$response = $this->getResponse($type, $url, $options);
|
$response = $this->getResponse($type, $url, $options);
|
||||||
|
|
||||||
if ((int) $response->getStatus() > 299 OR (int) $response->getStatus() < 200)
|
if ((int) $response->getStatus() > 299 || (int) $response->getStatus() < 200)
|
||||||
{
|
{
|
||||||
if ($logger)
|
if ($logger)
|
||||||
{
|
{
|
||||||
@ -177,7 +181,7 @@ trait KitsuTrait {
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Json::decode(wait($response->getBody()));
|
return Json::decode(wait($response->getBody()->buffer()));
|
||||||
}
|
}
|
||||||
catch (JsonException $e)
|
catch (JsonException $e)
|
||||||
{
|
{
|
||||||
@ -191,6 +195,7 @@ trait KitsuTrait {
|
|||||||
* Remove some boilerplate for get requests
|
* Remove some boilerplate for get requests
|
||||||
*
|
*
|
||||||
* @param mixed ...$args
|
* @param mixed ...$args
|
||||||
|
* @throws Throwable
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getRequest(...$args): array
|
protected function getRequest(...$args): array
|
||||||
@ -202,6 +207,7 @@ trait KitsuTrait {
|
|||||||
* Remove some boilerplate for patch requests
|
* Remove some boilerplate for patch requests
|
||||||
*
|
*
|
||||||
* @param mixed ...$args
|
* @param mixed ...$args
|
||||||
|
* @throws Throwable
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function patchRequest(...$args): array
|
protected function patchRequest(...$args): array
|
||||||
@ -213,6 +219,7 @@ trait KitsuTrait {
|
|||||||
* Remove some boilerplate for post requests
|
* Remove some boilerplate for post requests
|
||||||
*
|
*
|
||||||
* @param mixed ...$args
|
* @param mixed ...$args
|
||||||
|
* @throws Throwable
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function postRequest(...$args): array
|
protected function postRequest(...$args): array
|
||||||
@ -234,13 +241,14 @@ trait KitsuTrait {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON::decode(wait($response->getBody()), TRUE);
|
return JSON::decode(wait($response->getBody()->buffer()), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove some boilerplate for delete requests
|
* Remove some boilerplate for delete requests
|
||||||
*
|
*
|
||||||
* @param mixed ...$args
|
* @param mixed ...$args
|
||||||
|
* @throws Throwable
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function deleteRequest(...$args): bool
|
protected function deleteRequest(...$args): bool
|
@ -4,36 +4,45 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Kitsu;
|
namespace Aviat\AnimeClient\API\Kitsu;
|
||||||
|
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
use const Aviat\AnimeClient\SESSION_SEGMENT;
|
use const Aviat\AnimeClient\SESSION_SEGMENT;
|
||||||
|
|
||||||
use function Amp\Promise\wait;
|
use function Amp\Promise\wait;
|
||||||
use function Aviat\AnimeClient\getResponse;
|
use function Aviat\AnimeClient\getResponse;
|
||||||
|
|
||||||
use Amp\Artax\Request;
|
use Amp\Http\Client\Request;
|
||||||
use Aviat\AnimeClient\API\ListItemInterface;
|
use Aviat\AnimeClient\API\AbstractListItem;
|
||||||
use Aviat\AnimeClient\Types\FormItemData;
|
use Aviat\AnimeClient\Types\FormItemData;
|
||||||
use Aviat\Ion\Di\ContainerAware;
|
use Aviat\Ion\Di\ContainerAware;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CRUD operations for Kitsu list items
|
* CRUD operations for Kitsu list items
|
||||||
*/
|
*/
|
||||||
final class ListItem implements ListItemInterface {
|
final class ListItem extends AbstractListItem {
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
use KitsuTrait;
|
use KitsuTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @return Request
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function create(array $data): Request
|
public function create(array $data): Request
|
||||||
{
|
{
|
||||||
$body = [
|
$body = [
|
||||||
@ -78,6 +87,11 @@ final class ListItem implements ListItemInterface {
|
|||||||
->getFullRequest();
|
->getFullRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @return Request
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function delete(string $id): Request
|
public function delete(string $id): Request
|
||||||
{
|
{
|
||||||
$authHeader = $this->getAuthHeader();
|
$authHeader = $this->getAuthHeader();
|
||||||
@ -91,6 +105,11 @@ final class ListItem implements ListItemInterface {
|
|||||||
return $request->getFullRequest();
|
return $request->getFullRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @return array
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function get(string $id): array
|
public function get(string $id): array
|
||||||
{
|
{
|
||||||
$authHeader = $this->getAuthHeader();
|
$authHeader = $this->getAuthHeader();
|
||||||
@ -107,7 +126,7 @@ final class ListItem implements ListItemInterface {
|
|||||||
|
|
||||||
$request = $request->getFullRequest();
|
$request = $request->getFullRequest();
|
||||||
$response = getResponse($request);
|
$response = getResponse($request);
|
||||||
return Json::decode(wait($response->getBody()));
|
return Json::decode(wait($response->getBody()->buffer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function increment(string $id, FormItemData $data): Request
|
public function increment(string $id, FormItemData $data): Request
|
||||||
@ -115,6 +134,12 @@ final class ListItem implements ListItemInterface {
|
|||||||
return $this->update($id, $data);
|
return $this->update($id, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @param FormItemData $data
|
||||||
|
* @return Request
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function update(string $id, FormItemData $data): Request
|
public function update(string $id, FormItemData $data): Request
|
||||||
{
|
{
|
||||||
$authHeader = $this->getAuthHeader();
|
$authHeader = $this->getAuthHeader();
|
||||||
@ -137,6 +162,11 @@ final class ListItem implements ListItemInterface {
|
|||||||
return $request->getFullRequest();
|
return $request->getFullRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool|string
|
||||||
|
* @throws ContainerException
|
||||||
|
* @throws NotFoundException
|
||||||
|
*/
|
||||||
private function getAuthHeader()
|
private function getAuthHeader()
|
||||||
{
|
{
|
||||||
$cache = $this->getContainer()->get('cache');
|
$cache = $this->getContainer()->get('cache');
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ namespace Aviat\AnimeClient\API\Kitsu;
|
|||||||
|
|
||||||
use function Amp\Promise\wait;
|
use function Amp\Promise\wait;
|
||||||
|
|
||||||
use Amp\Artax\Request;
|
use Amp\Http\Client\Request;
|
||||||
use Aviat\AnimeClient\API\{
|
use Aviat\AnimeClient\API\{
|
||||||
CacheTrait,
|
CacheTrait,
|
||||||
JsonAPI,
|
JsonAPI,
|
||||||
@ -41,8 +41,13 @@ use Aviat\AnimeClient\Types\{
|
|||||||
FormItem,
|
FormItem,
|
||||||
MangaPage
|
MangaPage
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use Aviat\Banker\Exception\InvalidArgumentException;
|
||||||
use Aviat\Ion\{Di\ContainerAware, Json};
|
use Aviat\Ion\{Di\ContainerAware, Json};
|
||||||
|
|
||||||
|
use ReflectionException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kitsu API Model
|
* Kitsu API Model
|
||||||
*/
|
*/
|
||||||
@ -103,6 +108,7 @@ final class Model {
|
|||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function authenticate(string $username, string $password)
|
public function authenticate(string $username, string $password)
|
||||||
{
|
{
|
||||||
@ -120,7 +126,7 @@ final class Model {
|
|||||||
'password' => $password
|
'password' => $password
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$data = Json::decode(wait($response->getBody()));
|
$data = Json::decode(wait($response->getBody()->buffer()));
|
||||||
|
|
||||||
if (array_key_exists('error', $data))
|
if (array_key_exists('error', $data))
|
||||||
{
|
{
|
||||||
@ -142,6 +148,7 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function reAuthenticate(string $token)
|
public function reAuthenticate(string $token)
|
||||||
{
|
{
|
||||||
@ -156,7 +163,7 @@ final class Model {
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$data = Json::decode(wait($response->getBody()));
|
$data = Json::decode(wait($response->getBody()->buffer()));
|
||||||
|
|
||||||
if (array_key_exists('access_token', $data))
|
if (array_key_exists('access_token', $data))
|
||||||
{
|
{
|
||||||
@ -171,6 +178,7 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @return string
|
* @return string
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getUserIdByUsername(string $username = NULL): string
|
public function getUserIdByUsername(string $username = NULL): string
|
||||||
{
|
{
|
||||||
@ -206,7 +214,7 @@ final class Model {
|
|||||||
*/
|
*/
|
||||||
public function getCharacter(string $slug): array
|
public function getCharacter(string $slug): array
|
||||||
{
|
{
|
||||||
$data = $this->getRequest('characters', [
|
return $this->getRequest('characters', [
|
||||||
'query' => [
|
'query' => [
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'slug' => $slug,
|
'slug' => $slug,
|
||||||
@ -218,8 +226,6 @@ final class Model {
|
|||||||
'include' => 'castings.person,castings.media'
|
'include' => 'castings.person,castings.media'
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,6 +233,7 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getPerson(string $id): array
|
public function getPerson(string $id): array
|
||||||
{
|
{
|
||||||
@ -265,8 +272,7 @@ final class Model {
|
|||||||
*/
|
*/
|
||||||
public function getUserData(string $username): array
|
public function getUserData(string $username): array
|
||||||
{
|
{
|
||||||
// $userId = $this->getUserIdByUsername($username);
|
return $this->getRequest('users', [
|
||||||
$data = $this->getRequest('users', [
|
|
||||||
'query' => [
|
'query' => [
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'name' => $username,
|
'name' => $username,
|
||||||
@ -279,8 +285,6 @@ final class Model {
|
|||||||
'include' => 'waifu,favorites.item,stats'
|
'include' => 'waifu,favorites.item,stats'
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -399,6 +403,7 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param string $status - The watching status to filter the list with
|
* @param string $status - The watching status to filter the list with
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getAnimeList(string $status): array
|
public function getAnimeList(string $status): array
|
||||||
{
|
{
|
||||||
@ -421,6 +426,7 @@ final class Model {
|
|||||||
{
|
{
|
||||||
$item['included'] = $included;
|
$item['included'] = $included;
|
||||||
}
|
}
|
||||||
|
unset($item);
|
||||||
$transformed = $this->animeListTransformer->transformCollection($data['data']);
|
$transformed = $this->animeListTransformer->transformCollection($data['data']);
|
||||||
$keyed = [];
|
$keyed = [];
|
||||||
|
|
||||||
@ -441,6 +447,7 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param string $status - Optional status to filter by
|
* @param string $status - Optional status to filter by
|
||||||
* @return int
|
* @return int
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getAnimeListCount(string $status = '') : int
|
public function getAnimeListCount(string $status = '') : int
|
||||||
{
|
{
|
||||||
@ -472,6 +479,8 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function getFullRawAnimeList(array $options = [
|
public function getFullRawAnimeList(array $options = [
|
||||||
'include' => 'anime.mappings'
|
'include' => 'anime.mappings'
|
||||||
@ -507,6 +516,8 @@ final class Model {
|
|||||||
* Get all the anime entries, that are organized for output to html
|
* Get all the anime entries, that are organized for output to html
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws ReflectionException
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getFullOrganizedAnimeList(): array
|
public function getFullOrganizedAnimeList(): array
|
||||||
{
|
{
|
||||||
@ -564,6 +575,7 @@ final class Model {
|
|||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return Request
|
* @return Request
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getPagedAnimeList(int $limit, int $offset = 0, array $options = [
|
public function getPagedAnimeList(int $limit, int $offset = 0, array $options = [
|
||||||
'include' => 'anime.mappings'
|
'include' => 'anime.mappings'
|
||||||
@ -590,6 +602,8 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param string $status - The watching status to filter the list with
|
* @param string $status - The watching status to filter the list with
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function getRawAnimeList(string $status): array
|
public function getRawAnimeList(string $status): array
|
||||||
{
|
{
|
||||||
@ -647,6 +661,7 @@ final class Model {
|
|||||||
* @param int $limit - The number of list items to fetch per page
|
* @param int $limit - The number of list items to fetch per page
|
||||||
* @param int $offset - The page offset
|
* @param int $offset - The page offset
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getMangaList(string $status, int $limit = 200, int $offset = 0): array
|
public function getMangaList(string $status, int $limit = 200, int $offset = 0): array
|
||||||
{
|
{
|
||||||
@ -685,6 +700,7 @@ final class Model {
|
|||||||
{
|
{
|
||||||
$item['included'] = $included;
|
$item['included'] = $included;
|
||||||
}
|
}
|
||||||
|
unset($item);
|
||||||
|
|
||||||
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
|
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
|
||||||
|
|
||||||
@ -700,6 +716,7 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param string $status - Optional status to filter by
|
* @param string $status - Optional status to filter by
|
||||||
* @return int
|
* @return int
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getMangaListCount(string $status = '') : int
|
public function getMangaListCount(string $status = '') : int
|
||||||
{
|
{
|
||||||
@ -731,6 +748,8 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function getFullRawMangaList(array $options = [
|
public function getFullRawMangaList(array $options = [
|
||||||
'include' => 'manga.mappings'
|
'include' => 'manga.mappings'
|
||||||
@ -766,6 +785,8 @@ final class Model {
|
|||||||
* Get all Manga lists
|
* Get all Manga lists
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws ReflectionException
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getFullOrganizedMangaList(): array
|
public function getFullOrganizedMangaList(): array
|
||||||
{
|
{
|
||||||
@ -787,6 +808,7 @@ final class Model {
|
|||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return Request
|
* @return Request
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getPagedMangaList(int $limit, int $offset = 0, array $options = [
|
public function getPagedMangaList(int $limit, int $offset = 0, array $options = [
|
||||||
'include' => 'manga.mappings'
|
'include' => 'manga.mappings'
|
||||||
@ -845,10 +867,16 @@ final class Model {
|
|||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return Request
|
* @return Request
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function createListItem(array $data): Request
|
public function createListItem(array $data): ?Request
|
||||||
{
|
{
|
||||||
$data['user_id'] = $this->getUserIdByUsername($this->getUsername());
|
$data['user_id'] = $this->getUserIdByUsername($this->getUsername());
|
||||||
|
if ($data['id'] === NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->listItem->create($data);
|
return $this->listItem->create($data);
|
||||||
}
|
}
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ final class AnimeListTransformer extends AbstractTransformer {
|
|||||||
'title' => $title,
|
'title' => $title,
|
||||||
'titles' => $titles,
|
'titles' => $titles,
|
||||||
'slug' => $anime['slug'],
|
'slug' => $anime['slug'],
|
||||||
'show_type' => $this->string($anime['subtype'])->upperCaseFirst()->__toString(),
|
'show_type' => (string)$this->string($anime['subtype'])->upperCaseFirst(),
|
||||||
'cover_image' => $anime['posterImage']['small'],
|
'cover_image' => $anime['posterImage']['small'],
|
||||||
'genres' => $genres,
|
'genres' => $genres,
|
||||||
'streaming_links' => $streamingLinks,
|
'streaming_links' => $streamingLinks,
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -89,14 +89,14 @@ final class AnimeTransformer extends AbstractTransformer {
|
|||||||
|
|
||||||
if ( ! empty($characters['main']))
|
if ( ! empty($characters['main']))
|
||||||
{
|
{
|
||||||
uasort($characters['main'], function ($a, $b) {
|
uasort($characters['main'], static function ($a, $b) {
|
||||||
return $a['name'] <=> $b['name'];
|
return $a['name'] <=> $b['name'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($characters['supporting']))
|
if ( ! empty($characters['supporting']))
|
||||||
{
|
{
|
||||||
uasort($characters['supporting'], function ($a, $b) {
|
uasort($characters['supporting'], static function ($a, $b) {
|
||||||
return $a['name'] <=> $b['name'];
|
return $a['name'] <=> $b['name'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ final class AnimeTransformer extends AbstractTransformer {
|
|||||||
'genres' => $item['genres'],
|
'genres' => $item['genres'],
|
||||||
'id' => $item['id'],
|
'id' => $item['id'],
|
||||||
'included' => $item['included'],
|
'included' => $item['included'],
|
||||||
'show_type' => $this->string($item['showType'])->upperCaseFirst()->__toString(),
|
'show_type' => (string)$this->string($item['showType'])->upperCaseFirst(),
|
||||||
'slug' => $item['slug'],
|
'slug' => $item['slug'],
|
||||||
'staff' => $staff,
|
'staff' => $staff,
|
||||||
'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']),
|
'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']),
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -26,6 +26,10 @@ use Aviat\Ion\Transformer\AbstractTransformer;
|
|||||||
*/
|
*/
|
||||||
final class CharacterTransformer extends AbstractTransformer {
|
final class CharacterTransformer extends AbstractTransformer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $characterData
|
||||||
|
* @return Character
|
||||||
|
*/
|
||||||
public function transform($characterData): Character
|
public function transform($characterData): Character
|
||||||
{
|
{
|
||||||
$data = JsonAPI::organizeData($characterData);
|
$data = JsonAPI::organizeData($characterData);
|
||||||
@ -44,14 +48,14 @@ final class CharacterTransformer extends AbstractTransformer {
|
|||||||
{
|
{
|
||||||
if (array_key_exists('anime', $data['included']))
|
if (array_key_exists('anime', $data['included']))
|
||||||
{
|
{
|
||||||
uasort($data['included']['anime'], function ($a, $b) {
|
uasort($data['included']['anime'], static function ($a, $b) {
|
||||||
return $a['attributes']['canonicalTitle'] <=> $b['attributes']['canonicalTitle'];
|
return $a['attributes']['canonicalTitle'] <=> $b['attributes']['canonicalTitle'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('manga', $data['included']))
|
if (array_key_exists('manga', $data['included']))
|
||||||
{
|
{
|
||||||
uasort($data['included']['manga'], function ($a, $b) {
|
uasort($data['included']['manga'], static function ($a, $b) {
|
||||||
return $a['attributes']['canonicalTitle'] <=> $b['attributes']['canonicalTitle'];
|
return $a['attributes']['canonicalTitle'] <=> $b['attributes']['canonicalTitle'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -142,13 +146,12 @@ final class CharacterTransformer extends AbstractTransformer {
|
|||||||
foreach ($role['relationships']['person']['people'] as $pid => $peoples)
|
foreach ($role['relationships']['person']['people'] as $pid => $peoples)
|
||||||
{
|
{
|
||||||
$p = $peoples;
|
$p = $peoples;
|
||||||
}
|
|
||||||
|
|
||||||
$person = $p['attributes'];
|
$person = $p['attributes'];
|
||||||
$person['id'] = $pid;
|
$person['id'] = $pid;
|
||||||
$person['image'] = $person['image']['original'];
|
$person['image'] = $person['image']['original'];
|
||||||
|
|
||||||
uasort($role['relationships']['media']['anime'], function ($a, $b) {
|
uasort($role['relationships']['media']['anime'], static function ($a, $b) {
|
||||||
return $a['attributes']['canonicalTitle'] <=> $b['attributes']['canonicalTitle'];
|
return $a['attributes']['canonicalTitle'] <=> $b['attributes']['canonicalTitle'];
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -158,7 +161,9 @@ final class CharacterTransformer extends AbstractTransformer {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$output[$roleName][$language][] = $item;
|
$output[$roleName][$language][] = $item;
|
||||||
} else
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
foreach ($role['relationships']['person']['people'] as $pid => $person)
|
foreach ($role['relationships']['person']['people'] as $pid => $person)
|
||||||
{
|
{
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ final class MangaListTransformer extends AbstractTransformer {
|
|||||||
$titles = Kitsu::filterTitles($manga);
|
$titles = Kitsu::filterTitles($manga);
|
||||||
$title = array_shift($titles);
|
$title = array_shift($titles);
|
||||||
|
|
||||||
$map = new MangaListItem([
|
return new MangaListItem([
|
||||||
'id' => $item['id'],
|
'id' => $item['id'],
|
||||||
'mal_id' => $MALid,
|
'mal_id' => $MALid,
|
||||||
'chapters' => [
|
'chapters' => [
|
||||||
@ -103,7 +103,7 @@ final class MangaListTransformer extends AbstractTransformer {
|
|||||||
'slug' => $manga['slug'],
|
'slug' => $manga['slug'],
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'titles' => $titles,
|
'titles' => $titles,
|
||||||
'type' => $this->string($manga['subtype'])->upperCaseFirst()->__toString(),
|
'type' => (string)$this->string($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'],
|
||||||
@ -112,8 +112,6 @@ final class MangaListTransformer extends AbstractTransformer {
|
|||||||
'reread' => $item['attributes']['reconsumeCount'],
|
'reread' => $item['attributes']['reconsumeCount'],
|
||||||
'user_rating' => $rating,
|
'user_rating' => $rating,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -98,14 +98,14 @@ final class MangaTransformer extends AbstractTransformer {
|
|||||||
|
|
||||||
if ( ! empty($characters['main']))
|
if ( ! empty($characters['main']))
|
||||||
{
|
{
|
||||||
uasort($characters['main'], function ($a, $b) {
|
uasort($characters['main'], static function ($a, $b) {
|
||||||
return $a['name'] <=> $b['name'];
|
return $a['name'] <=> $b['name'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($characters['supporting']))
|
if ( ! empty($characters['supporting']))
|
||||||
{
|
{
|
||||||
uasort($characters['supporting'], function ($a, $b) {
|
uasort($characters['supporting'], static function ($a, $b) {
|
||||||
return $a['name'] <=> $b['name'];
|
return $a['name'] <=> $b['name'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -130,10 +130,14 @@ final class MangaTransformer extends AbstractTransformer {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function count(int $value = NULL)
|
/**
|
||||||
|
* @param int|null $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function count(int $value = NULL): string
|
||||||
{
|
{
|
||||||
return ((int)$value === 0)
|
return ((int)$value === 0)
|
||||||
? '-'
|
? '-'
|
||||||
: $value;
|
: (string)$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -25,6 +25,10 @@ use Aviat\Ion\Transformer\AbstractTransformer;
|
|||||||
*/
|
*/
|
||||||
final class PersonTransformer extends AbstractTransformer {
|
final class PersonTransformer extends AbstractTransformer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array|object $personData
|
||||||
|
* @return Person
|
||||||
|
*/
|
||||||
public function transform($personData): Person
|
public function transform($personData): Person
|
||||||
{
|
{
|
||||||
$data = JsonAPI::organizeData($personData);
|
$data = JsonAPI::organizeData($personData);
|
||||||
@ -78,7 +82,7 @@ final class PersonTransformer extends AbstractTransformer {
|
|||||||
|
|
||||||
$includedMedia = array_replace_recursive($existingMedia, $relatedMedia);
|
$includedMedia = array_replace_recursive($existingMedia, $relatedMedia);
|
||||||
|
|
||||||
uasort($includedMedia, function ($a, $b) {
|
uasort($includedMedia, static function ($a, $b) {
|
||||||
return $a['canonicalTitle'] <=> $b['canonicalTitle'];
|
return $a['canonicalTitle'] <=> $b['canonicalTitle'];
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -103,10 +107,10 @@ final class PersonTransformer extends AbstractTransformer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uasort($output['characters']['main'], function ($a, $b) {
|
uasort($output['characters']['main'], static function ($a, $b) {
|
||||||
return $a['character']['canonicalName'] <=> $b['character']['canonicalName'];
|
return $a['character']['canonicalName'] <=> $b['character']['canonicalName'];
|
||||||
});
|
});
|
||||||
uasort($output['characters']['supporting'], function ($a, $b) {
|
uasort($output['characters']['supporting'], static function ($a, $b) {
|
||||||
return $a['character']['canonicalName'] <=> $b['character']['canonicalName'];
|
return $a['character']['canonicalName'] <=> $b['character']['canonicalName'];
|
||||||
});
|
});
|
||||||
ksort($output['staff']);
|
ksort($output['staff']);
|
||||||
@ -114,14 +118,14 @@ final class PersonTransformer extends AbstractTransformer {
|
|||||||
{
|
{
|
||||||
if (array_key_exists('anime', $media))
|
if (array_key_exists('anime', $media))
|
||||||
{
|
{
|
||||||
uasort($media['anime'], function ($a, $b) {
|
uasort($media['anime'], static function ($a, $b) {
|
||||||
return $a['canonicalTitle'] <=> $b['canonicalTitle'];
|
return $a['canonicalTitle'] <=> $b['canonicalTitle'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('manga', $media))
|
if (array_key_exists('manga', $media))
|
||||||
{
|
{
|
||||||
uasort($media['manga'], function ($a, $b) {
|
uasort($media['manga'], static function ($a, $b) {
|
||||||
return $a['canonicalTitle'] <=> $b['canonicalTitle'];
|
return $a['canonicalTitle'] <=> $b['canonicalTitle'];
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -24,6 +24,9 @@ use Aviat\Ion\Transformer\AbstractTransformer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform user profile data for display
|
* Transform user profile data for display
|
||||||
|
*
|
||||||
|
* @param array|object $profileData
|
||||||
|
* @return User
|
||||||
*/
|
*/
|
||||||
final class UserTransformer extends AbstractTransformer {
|
final class UserTransformer extends AbstractTransformer {
|
||||||
public function transform($profileData): User
|
public function transform($profileData): User
|
||||||
@ -41,6 +44,7 @@ final class UserTransformer extends AbstractTransformer {
|
|||||||
$stats[$key] = $item['attributes']['statsData'];
|
$stats[$key] = $item['attributes']['statsData'];
|
||||||
unset($item);
|
unset($item);
|
||||||
}
|
}
|
||||||
|
unset($item);
|
||||||
|
|
||||||
$waifu = [];
|
$waifu = [];
|
||||||
if (array_key_exists('waifu', $rels))
|
if (array_key_exists('waifu', $rels))
|
||||||
@ -131,7 +135,7 @@ final class UserTransformer extends AbstractTransformer {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function organizeStats($stats, $data = []): array
|
private function organizeStats(array $stats, $data = []): array
|
||||||
{
|
{
|
||||||
$animeStats = [];
|
$animeStats = [];
|
||||||
$mangaStats = [];
|
$mangaStats = [];
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -4,22 +4,25 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API;
|
namespace Aviat\AnimeClient\API;
|
||||||
|
|
||||||
|
use Amp\Http\Client\Request;
|
||||||
use function Amp\call;
|
use function Amp\call;
|
||||||
use function Amp\Promise\{all, wait};
|
use function Amp\Promise\{all, wait};
|
||||||
use function Aviat\AnimeClient\getApiClient;
|
use function Aviat\AnimeClient\getApiClient;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to simplify making and validating simultaneous requests
|
* Class to simplify making and validating simultaneous requests
|
||||||
*/
|
*/
|
||||||
@ -35,7 +38,7 @@ final class ParallelAPIRequest {
|
|||||||
/**
|
/**
|
||||||
* Add a request
|
* Add a request
|
||||||
*
|
*
|
||||||
* @param string|\Amp\Artax\Request $request
|
* @param string|Request $request
|
||||||
* @param string|number $key
|
* @param string|number $key
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
@ -54,7 +57,7 @@ final class ParallelAPIRequest {
|
|||||||
/**
|
/**
|
||||||
* Add multiple requests
|
* Add multiple requests
|
||||||
*
|
*
|
||||||
* @param string[]|\Amp\Artax\Request[] $requests
|
* @param string[]|Request[] $requests
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function addRequests(array $requests): self
|
public function addRequests(array $requests): self
|
||||||
@ -67,7 +70,7 @@ final class ParallelAPIRequest {
|
|||||||
* Make the requests, and return the body for each
|
* Make the requests, and return the body for each
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function makeRequests(): array
|
public function makeRequests(): array
|
||||||
{
|
{
|
||||||
@ -77,9 +80,9 @@ final class ParallelAPIRequest {
|
|||||||
|
|
||||||
foreach ($this->requests as $key => $url)
|
foreach ($this->requests as $key => $url)
|
||||||
{
|
{
|
||||||
$promises[$key] = call(function () use ($client, $url) {
|
$promises[$key] = call(static function () use ($client, $url) {
|
||||||
$response = yield $client->request($url);
|
$response = yield $client->request($url);
|
||||||
return yield $response->getBody();
|
return yield $response->getBody()->buffer();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +93,7 @@ final class ParallelAPIRequest {
|
|||||||
* Make the requests and return the response objects
|
* Make the requests and return the response objects
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function getResponses(): array
|
public function getResponses(): array
|
||||||
{
|
{
|
||||||
@ -100,7 +103,7 @@ final class ParallelAPIRequest {
|
|||||||
|
|
||||||
foreach ($this->requests as $key => $url)
|
foreach ($this->requests as $key => $url)
|
||||||
{
|
{
|
||||||
$promises[$key] = call(function () use ($client, $url) {
|
$promises[$key] = call(static function () use ($client, $url) {
|
||||||
return yield $client->request($url);
|
return yield $client->request($url);
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -18,7 +18,10 @@ namespace Aviat\AnimeClient;
|
|||||||
|
|
||||||
use function Amp\Promise\wait;
|
use function Amp\Promise\wait;
|
||||||
|
|
||||||
use Amp\Artax\{Client, DefaultClient, Response};
|
use Amp\Http\Client\Request;
|
||||||
|
use Amp\Http\Client\Response;
|
||||||
|
use Amp\Http\Client\HttpClient;
|
||||||
|
use Amp\Http\Client\HttpClientBuilder;
|
||||||
|
|
||||||
use Aviat\Ion\ConfigInterface;
|
use Aviat\Ion\ConfigInterface;
|
||||||
use Yosymfony\Toml\{Toml, TomlBuilder};
|
use Yosymfony\Toml\{Toml, TomlBuilder};
|
||||||
@ -178,8 +181,8 @@ function checkFolderPermissions(ConfigInterface $config): array
|
|||||||
$publicDir = $config->get('asset_dir');
|
$publicDir = $config->get('asset_dir');
|
||||||
|
|
||||||
$pathMap = [
|
$pathMap = [
|
||||||
'app/config' => realpath(__DIR__ . '/../app/config'),
|
'app/config' => realpath(__DIR__ . '/../../app/config'),
|
||||||
'app/logs' => realpath(__DIR__ . '/../app/logs'),
|
'app/logs' => realpath(__DIR__ . '/../../app/logs'),
|
||||||
'public/images/avatars' => "{$publicDir}/images/avatars",
|
'public/images/avatars' => "{$publicDir}/images/avatars",
|
||||||
'public/images/anime' => "{$publicDir}/images/anime",
|
'public/images/anime' => "{$publicDir}/images/anime",
|
||||||
'public/images/characters' => "{$publicDir}/images/characters",
|
'public/images/characters' => "{$publicDir}/images/characters",
|
||||||
@ -218,23 +221,29 @@ function getApiClient ()
|
|||||||
|
|
||||||
if ($client === NULL)
|
if ($client === NULL)
|
||||||
{
|
{
|
||||||
$client = new DefaultClient;
|
$client = HttpClientBuilder::buildDefault();
|
||||||
$client->setOption(Client::OP_TRANSFER_TIMEOUT, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplify making a request with Artax
|
* Simplify making a request with Http\Client
|
||||||
*
|
*
|
||||||
* @param $request
|
* @param string|Request $request
|
||||||
* @return Response
|
* @return Response
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
function getResponse ($request): Response
|
function getResponse ($request): Response
|
||||||
{
|
{
|
||||||
$client = getApiClient();
|
$client = getApiClient();
|
||||||
|
|
||||||
|
if (is_string($request))
|
||||||
|
{
|
||||||
|
$request = new Request($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return wait($client->request($request));
|
return wait($client->request($request));
|
||||||
}
|
}
|
||||||
|
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ use Zend\Diactoros\{Response, ServerRequestFactory};
|
|||||||
/**
|
/**
|
||||||
* Base class for console command setup
|
* Base class for console command setup
|
||||||
*/
|
*/
|
||||||
class BaseCommand extends Command {
|
abstract class BaseCommand extends Command {
|
||||||
use CacheTrait;
|
use CacheTrait;
|
||||||
use ContainerAware;
|
use ContainerAware;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class BaseCommand extends Command {
|
|||||||
* @param string $message
|
* @param string $message
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function echoBox($message)
|
protected function echoBox($message): void
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ class BaseCommand extends Command {
|
|||||||
*/
|
*/
|
||||||
protected function setupContainer(): Container
|
protected function setupContainer(): Container
|
||||||
{
|
{
|
||||||
$APP_DIR = realpath(__DIR__ . '/../../app');
|
$APP_DIR = realpath(__DIR__ . '/../../../app');
|
||||||
$APPCONF_DIR = realpath("{$APP_DIR}/appConf/");
|
$APPCONF_DIR = realpath("{$APP_DIR}/appConf/");
|
||||||
$CONF_DIR = realpath("{$APP_DIR}/config/");
|
$CONF_DIR = realpath("{$APP_DIR}/config/");
|
||||||
$baseConfig = require $APPCONF_DIR . '/base_config.php';
|
$baseConfig = require $APPCONF_DIR . '/base_config.php';
|
||||||
@ -82,7 +82,7 @@ class BaseCommand extends Command {
|
|||||||
|
|
||||||
$configArray = array_replace_recursive($baseConfig, $config, $overrideConfig);
|
$configArray = array_replace_recursive($baseConfig, $config, $overrideConfig);
|
||||||
|
|
||||||
$di = static function ($configArray) use ($APP_DIR) {
|
$di = static function ($configArray) use ($APP_DIR): Container {
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@ -91,16 +91,19 @@ class BaseCommand extends Command {
|
|||||||
|
|
||||||
$app_logger = new Logger('animeclient');
|
$app_logger = new Logger('animeclient');
|
||||||
$app_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', Logger::NOTICE));
|
$app_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', Logger::NOTICE));
|
||||||
|
|
||||||
$kitsu_request_logger = new Logger('kitsu-request');
|
$kitsu_request_logger = new Logger('kitsu-request');
|
||||||
$kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE));
|
$kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE));
|
||||||
|
|
||||||
$anilistRequestLogger = new Logger('anilist-request');
|
$anilistRequestLogger = new Logger('anilist-request');
|
||||||
$anilistRequestLogger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/anilist_request-cli.log', Logger::NOTICE));
|
$anilistRequestLogger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/anilist_request-cli.log', Logger::NOTICE));
|
||||||
|
|
||||||
$container->setLogger($app_logger);
|
$container->setLogger($app_logger);
|
||||||
$container->setLogger($anilistRequestLogger, 'anilist-request');
|
$container->setLogger($anilistRequestLogger, 'anilist-request');
|
||||||
$container->setLogger($kitsu_request_logger, 'kitsu-request');
|
$container->setLogger($kitsu_request_logger, 'kitsu-request');
|
||||||
|
|
||||||
// Create Config Object
|
// Create Config Object
|
||||||
$container->set('config', static function() use ($configArray) {
|
$container->set('config', static function() use ($configArray): Config {
|
||||||
return new Config($configArray);
|
return new Config($configArray);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -126,7 +129,7 @@ class BaseCommand extends Command {
|
|||||||
$_FILES
|
$_FILES
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
$container->set('response', static function() {
|
$container->set('response', static function(): Response {
|
||||||
return new Response;
|
return new Response;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -136,7 +139,7 @@ class BaseCommand extends Command {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
$container->set('kitsu-model', static function($container) {
|
$container->set('kitsu-model', static function($container): Kitsu\Model {
|
||||||
$requestBuilder = new KitsuRequestBuilder();
|
$requestBuilder = new KitsuRequestBuilder();
|
||||||
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
||||||
|
|
||||||
@ -152,7 +155,7 @@ class BaseCommand extends Command {
|
|||||||
$model->setCache($cache);
|
$model->setCache($cache);
|
||||||
return $model;
|
return $model;
|
||||||
});
|
});
|
||||||
$container->set('anilist-model', static function ($container) {
|
$container->set('anilist-model', static function ($container): Anilist\Model {
|
||||||
$requestBuilder = new Anilist\AnilistRequestBuilder();
|
$requestBuilder = new Anilist\AnilistRequestBuilder();
|
||||||
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
||||||
|
|
||||||
@ -166,21 +169,21 @@ class BaseCommand extends Command {
|
|||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
});
|
});
|
||||||
$container->set('settings-model', static function($container) {
|
$container->set('settings-model', static function($container): Model\Settings {
|
||||||
$model = new Model\Settings($container->get('config'));
|
$model = new Model\Settings($container->get('config'));
|
||||||
$model->setContainer($container);
|
$model->setContainer($container);
|
||||||
return $model;
|
return $model;
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->set('auth', static function($container) {
|
$container->set('auth', static function($container): Kitsu\Auth {
|
||||||
return new Kitsu\Auth($container);
|
return new Kitsu\Auth($container);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->set('url-generator', static function($container) {
|
$container->set('url-generator', static function($container): UrlGenerator {
|
||||||
return new UrlGenerator($container);
|
return new UrlGenerator($container);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->set('util', static function($container) {
|
$container->set('util', static function($container): Util {
|
||||||
return new Util($container);
|
return new Util($container);
|
||||||
});
|
});
|
||||||
|
|
@ -4,18 +4,21 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Command;
|
namespace Aviat\AnimeClient\Command;
|
||||||
|
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the API Cache
|
* Clears the API Cache
|
||||||
*/
|
*/
|
||||||
@ -25,15 +28,15 @@ final class CacheClear extends BaseCommand {
|
|||||||
*
|
*
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute(array $args, array $options = []): void
|
public function execute(array $args, array $options = []): void
|
||||||
{
|
{
|
||||||
$this->setContainer($this->setupContainer());
|
$this->setContainer($this->setupContainer());
|
||||||
$cache = $this->container->get('cache');
|
|
||||||
$cache->clear();
|
$this->container->get('cache')->clear();
|
||||||
|
|
||||||
$this->echoBox('API Cache has been cleared.');
|
$this->echoBox('API Cache has been cleared.');
|
||||||
}
|
}
|
@ -4,18 +4,21 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Command;
|
namespace Aviat\AnimeClient\Command;
|
||||||
|
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the API Cache
|
* Clears the API Cache
|
||||||
*/
|
*/
|
||||||
@ -25,8 +28,8 @@ final class CachePrime extends BaseCommand {
|
|||||||
*
|
*
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute(array $args, array $options = []): void
|
public function execute(array $args, array $options = []): void
|
||||||
@ -50,8 +53,9 @@ final class CachePrime extends BaseCommand {
|
|||||||
$userIdItem->save();
|
$userIdItem->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prime anime list cache
|
|
||||||
$kitsuModel = $this->container->get('kitsu-model');
|
$kitsuModel = $this->container->get('kitsu-model');
|
||||||
|
|
||||||
|
// Prime anime list cache
|
||||||
$kitsuModel->getFullOrganizedAnimeList();
|
$kitsuModel->getFullOrganizedAnimeList();
|
||||||
|
|
||||||
// Prime manga list cache
|
// Prime manga list cache
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -4,26 +4,34 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @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\
|
use Aviat\AnimeClient\API\{
|
||||||
{Anilist\MissingIdException, FailedResponseException, JsonAPI, ParallelAPIRequest};
|
Anilist\MissingIdException,
|
||||||
|
FailedResponseException,
|
||||||
|
JsonAPI,
|
||||||
|
ParallelAPIRequest
|
||||||
|
};
|
||||||
use Aviat\AnimeClient\API\Anilist\Transformer\{
|
use Aviat\AnimeClient\API\Anilist\Transformer\{
|
||||||
AnimeListTransformer as AALT,
|
AnimeListTransformer as AALT,
|
||||||
MangaListTransformer as AMLT
|
MangaListTransformer as AMLT
|
||||||
};
|
};
|
||||||
|
use Aviat\AnimeClient\API\Anilist\Model as AnilistModel;
|
||||||
|
use Aviat\AnimeClient\API\Kitsu\Model as KitsuModel;
|
||||||
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
|
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
|
||||||
use Aviat\AnimeClient\Types\FormItem;
|
use Aviat\AnimeClient\Types\FormItem;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
@ -34,13 +42,13 @@ final class SyncLists extends BaseCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for making requests to Anilist API
|
* Model for making requests to Anilist API
|
||||||
* @var \Aviat\AnimeClient\API\Anilist\Model
|
* @var AnilistModel
|
||||||
*/
|
*/
|
||||||
protected $anilistModel;
|
protected $anilistModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for making requests to Kitsu API
|
* Model for making requests to Kitsu API
|
||||||
* @var \Aviat\AnimeClient\API\Kitsu\Model
|
* @var KitsuModel
|
||||||
*/
|
*/
|
||||||
protected $kitsuModel;
|
protected $kitsuModel;
|
||||||
|
|
||||||
@ -49,8 +57,8 @@ final class SyncLists extends BaseCommand {
|
|||||||
*
|
*
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function execute(array $args, array $options = []): void
|
public function execute(array $args, array $options = []): void
|
||||||
@ -169,8 +177,8 @@ final class SyncLists extends BaseCommand {
|
|||||||
* Format an Anilist anime list for comparison
|
* Format an Anilist anime list for comparison
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
protected function formatAnilistAnimeList(): array
|
protected function formatAnilistAnimeList(): array
|
||||||
{
|
{
|
||||||
@ -202,8 +210,8 @@ final class SyncLists extends BaseCommand {
|
|||||||
* Format an Anilist manga list for comparison
|
* Format an Anilist manga list for comparison
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
protected function formatAnilistMangaList(): array
|
protected function formatAnilistMangaList(): array
|
||||||
{
|
{
|
||||||
@ -596,6 +604,12 @@ final class SyncLists extends BaseCommand {
|
|||||||
}
|
}
|
||||||
else if ($action === 'create')
|
else if ($action === 'create')
|
||||||
{
|
{
|
||||||
|
$maybeRequest = $this->kitsuModel->createListItem($item);
|
||||||
|
if ($maybeRequest === NULL)
|
||||||
|
{
|
||||||
|
$this->echoBox("Skipped creating Kitsu {$type} due to missing id ¯\_(ツ)_/¯");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$requester->addRequest($this->kitsuModel->createListItem($item));
|
$requester->addRequest($this->kitsuModel->createListItem($item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,7 +690,6 @@ final class SyncLists extends BaseCommand {
|
|||||||
|
|
||||||
$responseData = Json::decode($response);
|
$responseData = Json::decode($response);
|
||||||
|
|
||||||
// $id = $itemsToUpdate[$key]['id'];
|
|
||||||
if ( ! array_key_exists('errors', $responseData))
|
if ( ! array_key_exists('errors', $responseData))
|
||||||
{
|
{
|
||||||
$verb = ($action === 'update') ? 'updated' : 'created';
|
$verb = ($action === 'update') ? 'updated' : 'created';
|
@ -4,19 +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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @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\Controller\Images;
|
use Aviat\AnimeClient\Controller\Images;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +27,7 @@ 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 \Aviat\AnimeClient\API\Kitsu\Model
|
* @var Model
|
||||||
*/
|
*/
|
||||||
protected $kitsuModel;
|
protected $kitsuModel;
|
||||||
|
|
||||||
@ -62,7 +63,11 @@ final class UpdateThumbnails extends ClearThumbnails {
|
|||||||
$this->echoBox('Finished regenerating all thumbnails');
|
$this->echoBox('Finished regenerating all thumbnails');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageList()
|
/**
|
||||||
|
* @return array array-key[][]
|
||||||
|
* @psalm-return array{anime: list<array-key>, manga: list<array-key>}
|
||||||
|
*/
|
||||||
|
public function getImageList(): array
|
||||||
{
|
{
|
||||||
$mangaList = $this->kitsuModel->getFullRawMangaList();
|
$mangaList = $this->kitsuModel->getFullRawMangaList();
|
||||||
$includes = JsonAPI::organizeIncludes($mangaList['included']);
|
$includes = JsonAPI::organizeIncludes($mangaList['included']);
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -18,9 +18,19 @@ namespace Aviat\AnimeClient;
|
|||||||
|
|
||||||
use function Aviat\Ion\_dir;
|
use function Aviat\Ion\_dir;
|
||||||
|
|
||||||
|
use Aura\Router\Generator;
|
||||||
|
use Aura\Session\Segment;
|
||||||
|
use Aviat\AnimeClient\API\Kitsu\Auth;
|
||||||
|
use Aviat\Ion\ConfigInterface;
|
||||||
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
use Aviat\Ion\Di\{
|
use Aviat\Ion\Di\{
|
||||||
ContainerAware,
|
ContainerAware,
|
||||||
ContainerInterface
|
ContainerInterface,
|
||||||
|
Exception\ContainerException,
|
||||||
|
Exception\NotFoundException
|
||||||
};
|
};
|
||||||
use Aviat\Ion\Exception\DoubleRenderException;
|
use Aviat\Ion\Exception\DoubleRenderException;
|
||||||
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
||||||
@ -35,31 +45,31 @@ class Controller {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The authentication object
|
* The authentication object
|
||||||
* @var \Aviat\AnimeClient\API\Kitsu\Auth $auth ;
|
* @var Auth $auth ;
|
||||||
*/
|
*/
|
||||||
protected $auth;
|
protected $auth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache manager
|
* Cache manager
|
||||||
* @var \Psr\Cache\CacheItemPoolInterface
|
* @var CacheItemPoolInterface
|
||||||
*/
|
*/
|
||||||
protected $cache;
|
protected $cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The global configuration object
|
* The global configuration object
|
||||||
* @var \Aviat\Ion\ConfigInterface $config
|
* @var ConfigInterface $config
|
||||||
*/
|
*/
|
||||||
public $config;
|
public $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request object
|
* Request object
|
||||||
* @var \Psr\Http\Message\ServerRequestInterface $request
|
* @var ServerRequestInterface $request
|
||||||
*/
|
*/
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response object
|
* Response object
|
||||||
* @var \Psr\Http\Message\ResponseInterface $response
|
* @var ResponseInterface $response
|
||||||
*/
|
*/
|
||||||
public $response;
|
public $response;
|
||||||
|
|
||||||
@ -71,13 +81,13 @@ class Controller {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Aura url generator
|
* Aura url generator
|
||||||
* @var \Aura\Router\Generator
|
* @var Generator
|
||||||
*/
|
*/
|
||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session segment
|
* Session segment
|
||||||
* @var \Aura\Session\Segment
|
* @var Segment
|
||||||
*/
|
*/
|
||||||
protected $session;
|
protected $session;
|
||||||
|
|
||||||
@ -91,8 +101,8 @@ class Controller {
|
|||||||
* Controller constructor.
|
* Controller constructor.
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -127,8 +137,8 @@ class Controller {
|
|||||||
* Set the current url in the session as the target of a future redirect
|
* Set the current url in the session as the target of a future redirect
|
||||||
*
|
*
|
||||||
* @param string|NULL $url
|
* @param string|NULL $url
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function setSessionRedirect(string $url = NULL): void
|
public function setSessionRedirect(string $url = NULL): void
|
||||||
{
|
{
|
||||||
@ -151,7 +161,7 @@ class Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $url)
|
if (NULL === $url)
|
||||||
{
|
{
|
||||||
$url = $util->isViewPage()
|
$url = $util->isViewPage()
|
||||||
? (string) $this->request->getUri()
|
? (string) $this->request->getUri()
|
||||||
@ -167,8 +177,8 @@ class Controller {
|
|||||||
* If one is not set, redirect to default url
|
* If one is not set, redirect to default url
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function sessionRedirect(): void
|
public function sessionRedirect(): void
|
||||||
@ -191,7 +201,6 @@ class Controller {
|
|||||||
'Forbidden',
|
'Forbidden',
|
||||||
'You must <a href="/login">log in</a> to perform this action.'
|
'You must <a href="/login">log in</a> to perform this action.'
|
||||||
);
|
);
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,8 +211,8 @@ class Controller {
|
|||||||
* @param string $template
|
* @param string $template
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function loadPartial($view, string $template, array $data = []): string
|
protected function loadPartial($view, string $template, array $data = []): string
|
||||||
@ -236,8 +245,8 @@ class Controller {
|
|||||||
* @param string $template
|
* @param string $template
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function renderFullPage($view, string $template, array $data): void
|
protected function renderFullPage($view, string $template, array $data): void
|
||||||
@ -266,8 +275,8 @@ class Controller {
|
|||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function notFound(
|
public function notFound(
|
||||||
@ -287,18 +296,18 @@ class Controller {
|
|||||||
* @param int $httpCode
|
* @param int $httpCode
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string $long_message
|
* @param string $longMessage
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function errorPage(int $httpCode, string $title, string $message, string $long_message = ''): void
|
public function errorPage(int $httpCode, string $title, string $message, string $longMessage = ''): void
|
||||||
{
|
{
|
||||||
$this->outputHTML('error', [
|
$this->outputHTML('error', [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'long_message' => $long_message
|
'long_message' => $longMessage
|
||||||
], NULL, $httpCode);
|
], NULL, $httpCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +351,7 @@ class Controller {
|
|||||||
/**
|
/**
|
||||||
* Helper for consistent page titles
|
* Helper for consistent page titles
|
||||||
*
|
*
|
||||||
* @param string[] $parts Title segments
|
* @param string ...$parts Title segments
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function formatTitle(string ...$parts) : string
|
public function formatTitle(string ...$parts) : string
|
||||||
@ -357,8 +366,8 @@ class Controller {
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function showMessage($view, string $type, string $message): string
|
protected function showMessage($view, string $type, string $message): string
|
||||||
@ -374,16 +383,16 @@ class Controller {
|
|||||||
*
|
*
|
||||||
* @param string $template
|
* @param string $template
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @param HtmlView|null $view
|
* @param HtmlView|NULL $view
|
||||||
* @param int $code
|
* @param int $code
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200): void
|
protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200): void
|
||||||
{
|
{
|
||||||
if (null === $view)
|
if (NULL === $view)
|
||||||
{
|
{
|
||||||
$view = new HtmlView($this->container);
|
$view = new HtmlView($this->container);
|
||||||
}
|
}
|
@ -4,26 +4,32 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @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 Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
|
||||||
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuWatchingStatus;
|
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuWatchingStatus;
|
||||||
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
|
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
|
||||||
use Aviat\AnimeClient\Types\FormItem;
|
use Aviat\AnimeClient\Types\FormItem;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for Anime-related pages
|
* Controller for Anime-related pages
|
||||||
*/
|
*/
|
||||||
@ -39,8 +45,8 @@ final class Anime extends BaseController {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -60,9 +66,10 @@ final class Anime extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param string|int $type - The section of the list
|
* @param string|int $type - The section of the list
|
||||||
* @param string $view - List or cover view
|
* @param string $view - List or cover view
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function index($type = KitsuWatchingStatus::WATCHING, string $view = NULL): void
|
public function index($type = KitsuWatchingStatus::WATCHING, string $view = NULL): void
|
||||||
@ -104,10 +111,11 @@ final class Anime extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Form to add an anime
|
* Form to add an anime
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \Aura\Router\Exception\RouteNotFound
|
* @throws RouteNotFound
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addForm(): void
|
public function addForm(): void
|
||||||
@ -128,8 +136,9 @@ final class Anime extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Add an anime to the list
|
* Add an anime to the list
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add(): void
|
public function add(): void
|
||||||
@ -168,6 +177,7 @@ final class Anime extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param string $status
|
* @param string $status
|
||||||
|
* @throws RouteNotFound
|
||||||
*/
|
*/
|
||||||
public function edit(string $id, $status = 'all'): void
|
public function edit(string $id, $status = 'all'): void
|
||||||
{
|
{
|
||||||
@ -204,8 +214,9 @@ final class Anime extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Update an anime item via a form submission
|
* Update an anime item via a form submission
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function formUpdate(): void
|
public function formUpdate(): void
|
||||||
@ -236,6 +247,7 @@ final class Anime extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Increase the watched count for an anime item
|
* Increase the watched count for an anime item
|
||||||
*
|
*
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function increment(): void
|
public function increment(): void
|
||||||
@ -266,6 +278,7 @@ final class Anime extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Remove an anime from the list
|
* Remove an anime from the list
|
||||||
*
|
*
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function delete(): void
|
public function delete(): void
|
||||||
@ -292,9 +305,9 @@ final class Anime extends BaseController {
|
|||||||
* View details of an anime
|
* View details of an anime
|
||||||
*
|
*
|
||||||
* @param string $animeId
|
* @param string $animeId
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function details(string $animeId): void
|
public function details(string $animeId): void
|
@ -4,24 +4,30 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @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 Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
use Aviat\AnimeClient\Model\{
|
use Aviat\AnimeClient\Model\{
|
||||||
Anime as AnimeModel,
|
Anime as AnimeModel,
|
||||||
AnimeCollection as AnimeCollectionModel
|
AnimeCollection as AnimeCollectionModel
|
||||||
};
|
};
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
use Aviat\Ion\Exception\DoubleRenderException;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for Anime collection pages
|
* Controller for Anime collection pages
|
||||||
@ -44,8 +50,8 @@ final class AnimeCollection extends BaseController {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -69,7 +75,7 @@ final class AnimeCollection extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Search for anime
|
* Search for anime
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Exception\DoubleRenderException
|
* @throws DoubleRenderException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function search(): void
|
public function search(): void
|
||||||
@ -83,9 +89,9 @@ final class AnimeCollection extends BaseController {
|
|||||||
* Show the anime collection page
|
* Show the anime collection page
|
||||||
*
|
*
|
||||||
* @param string $view
|
* @param string $view
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function view($view): void
|
public function view($view): void
|
||||||
@ -108,10 +114,10 @@ final class AnimeCollection extends BaseController {
|
|||||||
* Show the anime collection add/edit form
|
* Show the anime collection add/edit form
|
||||||
*
|
*
|
||||||
* @param integer|null $id
|
* @param integer|null $id
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \Aura\Router\Exception\RouteNotFound
|
* @throws RouteNotFound
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function form($id = NULL): void
|
public function form($id = NULL): void
|
||||||
@ -138,9 +144,9 @@ final class AnimeCollection extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Update a collection item
|
* Update a collection item
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function edit(): void
|
public function edit(): void
|
||||||
@ -173,9 +179,9 @@ final class AnimeCollection extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Add a collection item
|
* Add a collection item
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add(): void
|
public function add(): void
|
@ -4,22 +4,25 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Controller;
|
namespace Aviat\AnimeClient\Controller;
|
||||||
|
|
||||||
|
use Aviat\AnimeClient\API\Kitsu\Model;
|
||||||
use Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
use Aviat\AnimeClient\API\Kitsu\Transformer\CharacterTransformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer\CharacterTransformer;
|
||||||
|
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for character description pages
|
* Controller for character description pages
|
||||||
@ -27,7 +30,7 @@ use Aviat\Ion\Di\ContainerInterface;
|
|||||||
class Character extends BaseController {
|
class Character extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Aviat\AnimeClient\API\Kitsu\Model
|
* @var Model
|
||||||
*/
|
*/
|
||||||
private $model;
|
private $model;
|
||||||
|
|
||||||
@ -35,8 +38,8 @@ class Character extends BaseController {
|
|||||||
* Character constructor.
|
* Character constructor.
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
@ -4,24 +4,28 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Controller;
|
namespace Aviat\AnimeClient\Controller;
|
||||||
|
|
||||||
|
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
|
||||||
|
|
||||||
use function Amp\Promise\wait;
|
use function Amp\Promise\wait;
|
||||||
use function Aviat\AnimeClient\getResponse;
|
use function Aviat\AnimeClient\getResponse;
|
||||||
use function Aviat\AnimeClient\createPlaceholderImage;
|
use function Aviat\AnimeClient\createPlaceholderImage;
|
||||||
|
|
||||||
use Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for handling routes that don't fit elsewhere
|
* Controller for handling routes that don't fit elsewhere
|
||||||
*/
|
*/
|
||||||
@ -32,17 +36,14 @@ final class Images extends BaseController {
|
|||||||
* @param string $type The category of image
|
* @param string $type The category of image
|
||||||
* @param string $file The filename to look for
|
* @param string $file The filename to look for
|
||||||
* @param bool $display Whether to output the image to the server
|
* @param bool $display Whether to output the image to the server
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @throws \TypeError
|
|
||||||
* @throws \Error
|
|
||||||
* @throws \Throwable
|
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @throws Throwable
|
||||||
|
* @throws ContainerException
|
||||||
*/
|
*/
|
||||||
public function cache(string $type, string $file, $display = TRUE): void
|
public function cache(string $type, string $file, $display = TRUE): void
|
||||||
{
|
{
|
||||||
$currentUrl = $this->request->getUri()->__toString();
|
$currentUrl = (string)$this->request->getUri();
|
||||||
|
|
||||||
$kitsuUrl = 'https://media.kitsu.io/';
|
$kitsuUrl = 'https://media.kitsu.io/';
|
||||||
$fileName = str_replace('-original', '', $file);
|
$fileName = str_replace('-original', '', $file);
|
||||||
@ -129,7 +130,7 @@ final class Images extends BaseController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = wait($response->getBody());
|
$data = wait($response->getBody()->buffer());
|
||||||
|
|
||||||
[$origWidth] = getimagesizefromstring($data);
|
[$origWidth] = getimagesizefromstring($data);
|
||||||
$gdImg = imagecreatefromstring($data);
|
$gdImg = imagecreatefromstring($data);
|
@ -4,25 +4,30 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @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 Aviat\AnimeClient\Controller;
|
use Aviat\AnimeClient\Controller;
|
||||||
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
|
||||||
use Aviat\AnimeClient\API\Mapping\MangaReadingStatus;
|
use Aviat\AnimeClient\API\Mapping\MangaReadingStatus;
|
||||||
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
||||||
use Aviat\AnimeClient\Types\FormItem;
|
use Aviat\AnimeClient\Types\FormItem;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
use Aviat\Ion\{Json, StringWrapper};
|
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
|
||||||
|
use Aviat\Ion\Json;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for manga list
|
* Controller for manga list
|
||||||
@ -39,8 +44,8 @@ final class Manga extends Controller {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -59,9 +64,9 @@ final class Manga extends Controller {
|
|||||||
*
|
*
|
||||||
* @param string $status
|
* @param string $status
|
||||||
* @param string $view
|
* @param string $view
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function index($status = 'all', $view = ''): void
|
public function index($status = 'all', $view = ''): void
|
||||||
@ -103,10 +108,10 @@ final class Manga extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Form to add an manga
|
* Form to add an manga
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \Aura\Router\Exception\RouteNotFound
|
* @throws RouteNotFound
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addForm(): void
|
public function addForm(): void
|
||||||
@ -129,9 +134,10 @@ final class Manga extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Add an manga to the list
|
* Add an manga to the list
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @throws Throwable
|
||||||
|
* @throws ContainerException
|
||||||
*/
|
*/
|
||||||
public function add(): void
|
public function add(): void
|
||||||
{
|
{
|
||||||
@ -168,10 +174,10 @@ final class Manga extends Controller {
|
|||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param string $status
|
* @param string $status
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \Aura\Router\Exception\RouteNotFound
|
* @throws RouteNotFound
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function edit($id, $status = 'All'): void
|
public function edit($id, $status = 'All'): void
|
||||||
@ -210,9 +216,10 @@ final class Manga extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Update an manga item via a form submission
|
* Update an manga item via a form submission
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws Throwable
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @throws ContainerException
|
||||||
*/
|
*/
|
||||||
public function formUpdate(): void
|
public function formUpdate(): void
|
||||||
{
|
{
|
||||||
@ -228,7 +235,7 @@ final class Manga extends Controller {
|
|||||||
|
|
||||||
if ($full_result['statusCode'] === 200)
|
if ($full_result['statusCode'] === 200)
|
||||||
{
|
{
|
||||||
$this->setFlashMessage("Successfully updated manga.", 'success');
|
$this->setFlashMessage('Successfully updated manga.', 'success');
|
||||||
$this->cache->clear();
|
$this->cache->clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -242,6 +249,7 @@ final class Manga extends Controller {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment the progress of a manga item
|
* Increment the progress of a manga item
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function increment(): void
|
public function increment(): void
|
||||||
{
|
{
|
||||||
@ -265,8 +273,9 @@ final class Manga extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Remove an manga from the list
|
* Remove an manga from the list
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function delete(): void
|
public function delete(): void
|
||||||
@ -293,9 +302,10 @@ final class Manga extends Controller {
|
|||||||
* View details of an manga
|
* View details of an manga
|
||||||
*
|
*
|
||||||
* @param string $manga_id
|
* @param string $manga_id
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
|
* @throws Throwable
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function details($manga_id): void
|
public function details($manga_id): void
|
@ -4,25 +4,31 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @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 Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
use Aviat\Ion\Exception\DoubleRenderException;
|
||||||
use Aviat\AnimeClient\Model\{
|
use Aviat\AnimeClient\Model\{
|
||||||
Manga as MangaModel,
|
Manga as MangaModel,
|
||||||
MangaCollection as MangaCollectionModel
|
MangaCollection as MangaCollectionModel
|
||||||
};
|
};
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for manga collection pages
|
* Controller for manga collection pages
|
||||||
*/
|
*/
|
||||||
@ -44,8 +50,8 @@ final class MangaCollection extends BaseController {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
@ -65,7 +71,7 @@ final class MangaCollection extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Search for manga
|
* Search for manga
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Exception\DoubleRenderException
|
* @throws DoubleRenderException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function search(): void
|
public function search(): void
|
||||||
@ -79,9 +85,9 @@ final class MangaCollection extends BaseController {
|
|||||||
* Show the manga collection page
|
* Show the manga collection page
|
||||||
*
|
*
|
||||||
* @param string $view
|
* @param string $view
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function index($view): void
|
public function index($view): void
|
||||||
@ -104,10 +110,10 @@ final class MangaCollection extends BaseController {
|
|||||||
* Show the manga collection add/edit form
|
* Show the manga collection add/edit form
|
||||||
*
|
*
|
||||||
* @param integer|null $id
|
* @param integer|null $id
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \Aura\Router\Exception\RouteNotFound
|
* @throws RouteNotFound
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function form($id = NULL): void
|
public function form($id = NULL): void
|
||||||
@ -132,9 +138,9 @@ final class MangaCollection extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Update a collection item
|
* Update a collection item
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function edit(): void
|
public function edit(): void
|
||||||
@ -156,9 +162,9 @@ final class MangaCollection extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Add a collection item
|
* Add a collection item
|
||||||
*
|
*
|
||||||
* @throws \Aviat\Ion\Di\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add(): void
|
public function add(): void
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -4,22 +4,25 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Controller;
|
namespace Aviat\AnimeClient\Controller;
|
||||||
|
|
||||||
|
use Aviat\AnimeClient\API\Kitsu\Model;
|
||||||
use Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
use Aviat\AnimeClient\API\Kitsu\Transformer\PersonTransformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer\PersonTransformer;
|
||||||
|
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for People pages
|
* Controller for People pages
|
||||||
@ -27,7 +30,7 @@ use Aviat\Ion\Di\ContainerInterface;
|
|||||||
final class People extends BaseController {
|
final class People extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Aviat\AnimeClient\API\Kitsu\Model
|
* @var Model
|
||||||
*/
|
*/
|
||||||
private $model;
|
private $model;
|
||||||
|
|
||||||
@ -35,8 +38,8 @@ final class People extends BaseController {
|
|||||||
* People constructor.
|
* People constructor.
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
@ -4,20 +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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @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 Aviat\AnimeClient\API\Anilist\Model;
|
||||||
use Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for user settings
|
* Controller for user settings
|
||||||
@ -25,7 +29,7 @@ use Aviat\Ion\Di\ContainerInterface;
|
|||||||
final class Settings extends BaseController {
|
final class Settings extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Aviat\AnimeClient\API\Anilist\Model
|
* @var Model
|
||||||
*/
|
*/
|
||||||
private $anilistModel;
|
private $anilistModel;
|
||||||
|
|
||||||
@ -38,8 +42,8 @@ final class Settings extends BaseController {
|
|||||||
* Settings constructor.
|
* Settings constructor.
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -75,7 +79,7 @@ final class Settings extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* Attempt to save the user's settings
|
* Attempt to save the user's settings
|
||||||
*
|
*
|
||||||
* @throws \Aura\Router\Exception\RouteNotFound
|
* @throws RouteNotFound
|
||||||
*/
|
*/
|
||||||
public function update(): void
|
public function update(): void
|
||||||
{
|
{
|
@ -4,22 +4,25 @@
|
|||||||
*
|
*
|
||||||
* 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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Controller;
|
namespace Aviat\AnimeClient\Controller;
|
||||||
|
|
||||||
|
use Aviat\AnimeClient\API\Kitsu\Model;
|
||||||
use Aviat\AnimeClient\API\Kitsu\Transformer\UserTransformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer\UserTransformer;
|
||||||
use Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
|
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for handling routes that don't fit elsewhere
|
* Controller for handling routes that don't fit elsewhere
|
||||||
@ -27,7 +30,7 @@ use Aviat\Ion\Di\ContainerInterface;
|
|||||||
final class User extends BaseController {
|
final class User extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Aviat\AnimeClient\API\Kitsu\Model
|
* @var Model
|
||||||
*/
|
*/
|
||||||
private $kitsuModel;
|
private $kitsuModel;
|
||||||
|
|
||||||
@ -35,8 +38,8 @@ final class User extends BaseController {
|
|||||||
* User constructor.
|
* User constructor.
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
@ -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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -18,13 +18,16 @@ namespace Aviat\AnimeClient;
|
|||||||
|
|
||||||
use function Aviat\Ion\_dir;
|
use function Aviat\Ion\_dir;
|
||||||
|
|
||||||
use Aura\Router\{Matcher, Rule};
|
use Aura\Router\{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\StringWrapper;
|
||||||
|
|
||||||
|
use LogicException;
|
||||||
|
use ReflectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic routing/ dispatch
|
* Basic routing/ dispatch
|
||||||
*/
|
*/
|
||||||
@ -74,7 +77,7 @@ final class Dispatcher extends RoutingBase {
|
|||||||
/**
|
/**
|
||||||
* Get the current route object, if one matches
|
* Get the current route object, if one matches
|
||||||
*
|
*
|
||||||
* @return \Aura\Router\Route|false
|
* @return Route|false
|
||||||
*/
|
*/
|
||||||
public function getRoute()
|
public function getRoute()
|
||||||
{
|
{
|
||||||
@ -109,6 +112,7 @@ final class Dispatcher extends RoutingBase {
|
|||||||
*
|
*
|
||||||
* @param object|null $route
|
* @param object|null $route
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function __invoke($route = NULL): void
|
public function __invoke($route = NULL): void
|
||||||
{
|
{
|
||||||
@ -125,14 +129,7 @@ final class Dispatcher extends RoutingBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($route)
|
if ( ! $route)
|
||||||
{
|
|
||||||
$parsed = $this->processRoute(new Friend($route));
|
|
||||||
$controllerName = $parsed['controller_name'];
|
|
||||||
$actionMethod = $parsed['action_method'];
|
|
||||||
$params = $parsed['params'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// If not route was matched, return an appropriate http
|
// If not route was matched, return an appropriate http
|
||||||
// error message
|
// error message
|
||||||
@ -140,8 +137,15 @@ final class Dispatcher extends RoutingBase {
|
|||||||
$controllerName = DEFAULT_CONTROLLER;
|
$controllerName = DEFAULT_CONTROLLER;
|
||||||
$actionMethod = $errorRoute['action_method'];
|
$actionMethod = $errorRoute['action_method'];
|
||||||
$params = $errorRoute['params'];
|
$params = $errorRoute['params'];
|
||||||
|
$this->call($controllerName, $actionMethod, $params);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$parsed = $this->processRoute(new Friend($route));
|
||||||
|
$controllerName = $parsed['controller_name'];
|
||||||
|
$actionMethod = $parsed['action_method'];
|
||||||
|
$params = $parsed['params'];
|
||||||
|
|
||||||
$this->call($controllerName, $actionMethod, $params);
|
$this->call($controllerName, $actionMethod, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,20 +153,21 @@ final class Dispatcher extends RoutingBase {
|
|||||||
* Parse out the arguments for the appropriate controller for
|
* Parse out the arguments for the appropriate controller for
|
||||||
* the current route
|
* the current route
|
||||||
*
|
*
|
||||||
* @param \Aura\Router\Route $route
|
* @param Route $route
|
||||||
* @throws \LogicException
|
* @throws LogicException
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function processRoute($route): array
|
protected function processRoute($route): array
|
||||||
{
|
{
|
||||||
|
if ( ! array_key_exists('controller', $route->attributes))
|
||||||
|
{
|
||||||
|
throw new LogicException('Missing controller');
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('controller', $route->attributes))
|
if (array_key_exists('controller', $route->attributes))
|
||||||
{
|
{
|
||||||
$controllerName = $route->attributes['controller'];
|
$controllerName = $route->attributes['controller'];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new \LogicException('Missing controller');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the full namespace for a controller if a short name is given
|
// Get the full namespace for a controller if a short name is given
|
||||||
if (strpos($controllerName, '\\') === FALSE)
|
if (strpos($controllerName, '\\') === FALSE)
|
||||||
@ -249,7 +254,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 = $this->string($rawClassName)->dasherize()->__toString();
|
$path = (string)$this->string($rawClassName)->dasherize();
|
||||||
$className = trim($defaultNamespace . '\\' . $rawClassName, '\\');
|
$className = trim($defaultNamespace . '\\' . $rawClassName, '\\');
|
||||||
|
|
||||||
$controllers[$path] = $className;
|
$controllers[$path] = $className;
|
||||||
@ -296,7 +301,7 @@ final class Dispatcher extends RoutingBase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the appropriate params for the error page
|
* Get the appropriate params for the error page
|
||||||
* pased on the failed route
|
* passed on the failed route
|
||||||
*
|
*
|
||||||
* @return array|false
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
@ -388,9 +393,9 @@ final class Dispatcher extends RoutingBase {
|
|||||||
if ( ! array_key_exists('tokens', $route))
|
if ( ! array_key_exists('tokens', $route))
|
||||||
{
|
{
|
||||||
$routes[] = $this->router->$add($name, $path)->defaults($route);
|
$routes[] = $this->router->$add($name, $path)->defaults($route);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$tokens = $route['tokens'];
|
$tokens = $route['tokens'];
|
||||||
unset($route['tokens']);
|
unset($route['tokens']);
|
||||||
|
|
||||||
@ -398,7 +403,6 @@ final class Dispatcher extends RoutingBase {
|
|||||||
->defaults($route)
|
->defaults($route)
|
||||||
->tokens($tokens);
|
->tokens($tokens);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $routes;
|
return $routes;
|
||||||
}
|
}
|
@ -4,19 +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.1
|
* PHP version 7.3
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package HummingbirdAnimeClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2018 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.1
|
* @version 4.2
|
||||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient;
|
namespace Aviat\AnimeClient;
|
||||||
|
|
||||||
|
use Aura\Html\HelperLocator;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
use Aviat\Ion\Di\Exception\ContainerException;
|
||||||
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper object to manage form generation, especially for config editing
|
* Helper object to manage form generation, especially for config editing
|
||||||
@ -25,7 +28,7 @@ final class FormGenerator {
|
|||||||
/**
|
/**
|
||||||
* Html generation helper
|
* Html generation helper
|
||||||
*
|
*
|
||||||
* @var \Aura\Html\HelperLocator
|
* @var HelperLocator
|
||||||
*/
|
*/
|
||||||
private $helper;
|
private $helper;
|
||||||
|
|
||||||
@ -33,8 +36,8 @@ final class FormGenerator {
|
|||||||
* FormGenerator constructor.
|
* FormGenerator constructor.
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
* @throws ContainerException
|
||||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -51,19 +54,21 @@ final class FormGenerator {
|
|||||||
public function generate(string $name, array $form): string
|
public function generate(string $name, array $form): string
|
||||||
{
|
{
|
||||||
$type = $form['type'];
|
$type = $form['type'];
|
||||||
|
$display = $form['display'] ?? TRUE;
|
||||||
|
$value = $form['value'] ?? '';
|
||||||
|
|
||||||
if ($form['display'] === FALSE)
|
if ($display === FALSE)
|
||||||
{
|
{
|
||||||
return $this->helper->input([
|
return (string)$this->helper->input([
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $form['value'],
|
'value' => $value,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $form['value'],
|
'value' => $value,
|
||||||
'attribs' => [
|
'attribs' => [
|
||||||
'id' => $name,
|
'id' => $name,
|
||||||
],
|
],
|
||||||
@ -92,7 +97,7 @@ final class FormGenerator {
|
|||||||
|
|
||||||
foreach (['readonly', 'disabled'] as $key)
|
foreach (['readonly', 'disabled'] as $key)
|
||||||
{
|
{
|
||||||
if ($form[$key] !== FALSE)
|
if (array_key_exists($key, $form) && $form[$key] !== FALSE)
|
||||||
{
|
{
|
||||||
$params['attribs'][$key] = $form[$key];
|
$params['attribs'][$key] = $form[$key];
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user