Version 5.1 - All the GraphQL #32
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -14,9 +14,6 @@
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bootstrap / Dependency Injection
|
||||
*/
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aura\Html\HelperLocatorFactory;
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -12,3 +12,4 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -4,7 +4,8 @@ $animeclient_file_patterns = [
|
||||
'app/config/*.php',
|
||||
'app/bootstrap.php',
|
||||
'src/functions.php',
|
||||
'src/*.php'
|
||||
'src/*.php',
|
||||
'tests/**/*.php'
|
||||
];
|
||||
|
||||
if ( ! function_exists('glob_recursive'))
|
||||
@ -26,21 +27,30 @@ if ( ! function_exists('glob_recursive'))
|
||||
|
||||
function get_text_to_replace($tokens)
|
||||
{
|
||||
if ($tokens[0][0] !== T_OPEN_TAG)
|
||||
$output = '';
|
||||
|
||||
// Tokens have the follow structure if arrays:
|
||||
// [0] => token type constant
|
||||
// [1] => raw sytax parsed to that token
|
||||
// [2] => line number
|
||||
foreach($tokens as $token)
|
||||
{
|
||||
return NULL;
|
||||
// Since we only care about opening docblocks,
|
||||
// bail out when we get to the namespace token
|
||||
if (is_array($token) && $token[0] === T_NAMESPACE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// If there is already a docblock, as the second token after the
|
||||
// open tag, get the contents of that token to replace
|
||||
if ($tokens[1][0] === T_DOC_COMMENT)
|
||||
if (is_array($token))
|
||||
{
|
||||
return "<?php\n" . $tokens[1][1];
|
||||
$token = $token[1];
|
||||
}
|
||||
else if ($tokens[1][0] !== T_DOC_COMMENT)
|
||||
{
|
||||
return "<?php";
|
||||
|
||||
$output .= $token;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function get_tokens($source)
|
||||
@ -53,11 +63,17 @@ function replace_files(array $files, $template)
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$source = file_get_contents($file);
|
||||
|
||||
if (stripos($source, 'namespace') === FALSE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$tokens = get_tokens($source);
|
||||
$text_to_replace = get_text_to_replace($tokens);
|
||||
|
||||
$header = file_get_contents(__DIR__ . $template);
|
||||
$new_text = "<?php\n{$header}";
|
||||
$new_text = "<?php declare(strict_types=1);\n{$header}";
|
||||
|
||||
$new_source = str_replace($text_to_replace, $new_text, $source);
|
||||
file_put_contents($file, $new_source);
|
||||
|
@ -40,6 +40,6 @@
|
||||
"consolidation/robo": "~1.0@RC",
|
||||
"henrikbjorn/lurker": "^1.1.0",
|
||||
"symfony/var-dumper": "^3.1",
|
||||
"squizlabs/php_codesniffer": "^3.0.0@alpha"
|
||||
"squizlabs/php_codesniffer": "^3.0.0@beta"
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -13,13 +13,12 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\View\HttpView;
|
||||
use Aviat\Ion\View\HtmlView;
|
||||
use Aviat\Ion\View\JsonView;
|
||||
use Doctrine\Instantiator\Exception\InvalidArgumentException;
|
||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Controller base, defines output methods
|
||||
@ -28,7 +27,7 @@ use Doctrine\Instantiator\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class Controller {
|
||||
|
||||
use \Aviat\Ion\Di\ContainerAware;
|
||||
use ContainerAware;
|
||||
|
||||
/**
|
||||
* Cache manager
|
||||
@ -166,7 +165,7 @@ class Controller {
|
||||
|
||||
if (is_null($url))
|
||||
{
|
||||
$url = ($util->is_view_page())
|
||||
$url = $util->is_view_page()
|
||||
? $this->request->url->get()
|
||||
: $server_params['HTTP_REFERER'];
|
||||
}
|
||||
@ -197,9 +196,9 @@ class Controller {
|
||||
* Get a class member
|
||||
*
|
||||
* @param string $key
|
||||
* @return object
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
public function __get(string $key)
|
||||
{
|
||||
$allowed = ['response', 'config'];
|
||||
|
||||
@ -217,7 +216,7 @@ class Controller {
|
||||
* @param HtmlView $view
|
||||
* @param string $template
|
||||
* @param array $data
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
* @return string
|
||||
*/
|
||||
protected function load_partial($view, $template, array $data = [])
|
||||
@ -230,17 +229,17 @@ class Controller {
|
||||
}
|
||||
|
||||
$route = $router->get_route();
|
||||
$data['route_path'] = ($route) ? $router->get_route()->path : "";
|
||||
$data['route_path'] = $route ? $router->get_route()->path : '';
|
||||
|
||||
|
||||
$template_path = _dir($this->config->get('view_path'), "{$template}.php");
|
||||
|
||||
if ( ! is_file($template_path))
|
||||
{
|
||||
throw new \InvalidArgumentException("Invalid template : {$template}");
|
||||
throw new InvalidArgumentException("Invalid template : {$template}");
|
||||
}
|
||||
|
||||
return $view->render_template($template_path, (array)$data);
|
||||
return $view->renderTemplate($template_path, (array)$data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -271,13 +270,13 @@ class Controller {
|
||||
* @param string $status
|
||||
* @return void
|
||||
*/
|
||||
public function login($status = "")
|
||||
public function login(string $status = '')
|
||||
{
|
||||
$message = "";
|
||||
$message = '';
|
||||
|
||||
$view = new HtmlView($this->container);
|
||||
|
||||
if ($status !== "")
|
||||
if ($status !== '')
|
||||
{
|
||||
$message = $this->show_message($view, 'error', $status);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -13,6 +13,7 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use Aviat\Ion\Json;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -13,6 +13,7 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -33,17 +33,17 @@ class AnimeListTransformer extends AbstractTransformer {
|
||||
public function transform($item)
|
||||
{
|
||||
$anime =& $item['anime'];
|
||||
$genres = $this->linearize_genres($item['anime']['genres']);
|
||||
$genres = $this->linearizeGenres($item['anime']['genres']);
|
||||
|
||||
$rating = NULL;
|
||||
if ($item['rating']['type'] === 'advanced')
|
||||
{
|
||||
$rating = (is_numeric($item['rating']['value']))
|
||||
? intval(2 * $item['rating']['value'])
|
||||
$rating = is_numeric($item['rating']['value'])
|
||||
? (int) 2 * $item['rating']['value']
|
||||
: '-';
|
||||
}
|
||||
|
||||
$total_episodes = (is_numeric($anime['episode_count']))
|
||||
$total_episodes = is_numeric($anime['episode_count'])
|
||||
? $anime['episode_count']
|
||||
: '-';
|
||||
|
||||
@ -54,7 +54,7 @@ class AnimeListTransformer extends AbstractTransformer {
|
||||
// a subset of the main title, don't list the
|
||||
// alternate title
|
||||
$not_subset = stripos($anime['title'], $anime['alternate_title']) === FALSE;
|
||||
$diff = levenshtein($anime['title'], $anime['alternate_title']);
|
||||
$diff = levenshtein($anime['title'], $anime['alternate_title'] ?? '');
|
||||
if ($not_subset && $diff >= 5)
|
||||
{
|
||||
$alternate_title = $anime['alternate_title'];
|
||||
@ -129,14 +129,14 @@ class AnimeListTransformer extends AbstractTransformer {
|
||||
/**
|
||||
* Simplify structure of genre list
|
||||
*
|
||||
* @param array $raw_genres
|
||||
* @param array $rawGenres
|
||||
* @return array
|
||||
*/
|
||||
protected function linearize_genres(array $raw_genres)
|
||||
protected function linearizeGenres(array $rawGenres): array
|
||||
{
|
||||
$genres = [];
|
||||
|
||||
foreach ($raw_genres as $genre)
|
||||
foreach ($rawGenres as $genre)
|
||||
{
|
||||
$genres[] = $genre['name'];
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\{ArrayWrapper, StringWrapper};
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
|
||||
/**
|
||||
@ -23,8 +24,8 @@ use Aviat\Ion\Di\ContainerInterface;
|
||||
*/
|
||||
class MenuGenerator extends UrlGenerator {
|
||||
|
||||
use \Aviat\Ion\StringWrapper;
|
||||
use \Aviat\Ion\ArrayWrapper;
|
||||
use ArrayWrapper;
|
||||
use StringWrapper;
|
||||
|
||||
/**
|
||||
* Html generation helper
|
||||
@ -87,7 +88,7 @@ class MenuGenerator extends UrlGenerator {
|
||||
$parsed_config = $this->parse_config($menus);
|
||||
|
||||
// Bail out early on invalid menu
|
||||
if ( ! $this->arr($parsed_config)->has_key($menu))
|
||||
if ( ! $this->arr($parsed_config)->hasKey($menu))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -13,6 +13,7 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
@ -160,7 +161,7 @@ class API extends Model {
|
||||
* @param string $sort_key
|
||||
* @return void
|
||||
*/
|
||||
protected function sort_by_name(&$array, $sort_key)
|
||||
protected function sort_by_name(array &$array, string $sort_key)
|
||||
{
|
||||
$sort = [];
|
||||
|
||||
@ -180,7 +181,7 @@ class API extends Model {
|
||||
* @param string $password
|
||||
* @return string|false
|
||||
*/
|
||||
public function authenticate($username, $password)
|
||||
public function authenticate(string $username, string $password)
|
||||
{
|
||||
$response = $this->post(AnimeClient::HUMMINGBIRD_AUTH_URL, [
|
||||
'form_params' => [
|
||||
@ -191,7 +192,7 @@ class API extends Model {
|
||||
|
||||
if ($response->getStatusCode() === 201)
|
||||
{
|
||||
return json_decode($response->getBody(), TRUE);
|
||||
return json_decode((string)$response->getBody(), TRUE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -205,7 +206,7 @@ class API extends Model {
|
||||
* @param string $status
|
||||
* @return array
|
||||
*/
|
||||
protected function _get_list_from_api($status)
|
||||
protected function _get_list_from_api(string $status): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -208,13 +208,13 @@ class Anime extends API {
|
||||
* @param string $status
|
||||
* @return array
|
||||
*/
|
||||
protected function _get_list_from_api($status = "all")
|
||||
protected function _get_list_from_api(string $status = "all"): array
|
||||
{
|
||||
$config = [
|
||||
'allow_redirects' => FALSE
|
||||
];
|
||||
|
||||
if ($status !== "all")
|
||||
if ($status !== 'all')
|
||||
{
|
||||
$config['query']['status'] = $status;
|
||||
}
|
||||
@ -266,7 +266,7 @@ class Anime extends API {
|
||||
{
|
||||
$api_data = Json::decode($response->getBody(), TRUE);
|
||||
$transformer = new AnimeListTransformer();
|
||||
$transformed = $transformer->transform_collection($api_data);
|
||||
$transformed = $transformer->transformCollection($api_data);
|
||||
return $transformed;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -13,6 +13,7 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -16,11 +16,11 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use GuzzleHttp\Cookie\SetCookie;
|
||||
|
||||
use Aviat\Ion\Json;
|
||||
use Aviat\AnimeClient\Hummingbird\Transformer;
|
||||
use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus;
|
||||
use Aviat\Ion\Json;
|
||||
use GuzzleHttp\Cookie\SetCookie;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Model for handling requests dealing with the manga list
|
||||
@ -59,7 +59,7 @@ class Manga extends API {
|
||||
* @param string|null $json
|
||||
* @return array
|
||||
*/
|
||||
protected function _manga_api_call($type, $url, $json = NULL)
|
||||
protected function _manga_api_call(string $type, string $url, $json = NULL): array
|
||||
{
|
||||
$token = $this->container->get('auth')
|
||||
->get_auth_token();
|
||||
@ -144,7 +144,7 @@ class Manga extends API {
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
* @throws \RuntimeException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function search($name)
|
||||
{
|
||||
@ -162,10 +162,10 @@ class Manga extends API {
|
||||
|
||||
if ((int) $response->getStatusCode() !== 200)
|
||||
{
|
||||
$logger->warning("Non 200 response for search api call");
|
||||
$logger->warning('Non 200 response for search api call');
|
||||
$logger->warning($response->getBody());
|
||||
|
||||
throw new \RuntimeException($response->getEffectiveUrl());
|
||||
throw new RuntimeException($response->getEffectiveUrl());
|
||||
}
|
||||
|
||||
return Json::decode($response->getBody(), TRUE);
|
||||
@ -189,7 +189,7 @@ class Manga extends API {
|
||||
* @param string $status
|
||||
* @return array
|
||||
*/
|
||||
public function _get_list_from_api($status = "All")
|
||||
public function _get_list_from_api(string $status = "All"): array
|
||||
{
|
||||
$config = [
|
||||
'query' => [
|
||||
@ -220,11 +220,9 @@ class Manga extends API {
|
||||
return [];
|
||||
}
|
||||
|
||||
$zippered_data = $this->zipper_lists($api_data);
|
||||
$zipperedData = $this->zipperLists($api_data);
|
||||
$transformer = new Transformer\MangaListTransformer();
|
||||
$transformed_data = $transformer->transform_collection($zippered_data);
|
||||
|
||||
return $transformed_data;
|
||||
return $transformer->transformCollection($zipperedData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -281,7 +279,7 @@ class Manga extends API {
|
||||
* @param array $raw_data
|
||||
* @return array
|
||||
*/
|
||||
private function zipper_lists($raw_data)
|
||||
private function zipperLists($raw_data)
|
||||
{
|
||||
return (new Transformer\MangaListsZipper($raw_data))->transform();
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -13,6 +13,7 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -13,6 +13,7 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -91,7 +91,7 @@ class Util {
|
||||
{
|
||||
$url = $this->container->get('request')
|
||||
->getUri();
|
||||
$page_segments = explode("/", $url);
|
||||
$page_segments = explode("/", (string) $url);
|
||||
|
||||
$intersect = array_intersect($page_segments, self::$form_pages);
|
||||
|
||||
|
@ -1,11 +1,7 @@
|
||||
<?php
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
|
||||
use Aviat\Ion\Friend;
|
||||
use Aviat\Ion\Json;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
||||
use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus;
|
||||
|
||||
class MangaModelTest extends AnimeClient_TestCase {
|
||||
|
||||
@ -22,7 +18,7 @@ class MangaModelTest extends AnimeClient_TestCase {
|
||||
$raw_data = Json::decodeFile($this->mockDir . '/manga.json');
|
||||
$expected = Json::decodeFile($this->mockDir . '/manga-zippered.json');
|
||||
|
||||
$this->assertEquals($expected, $this->model->zipper_lists($raw_data));
|
||||
$this->assertEquals($expected, $this->model->zipperLists($raw_data));
|
||||
}
|
||||
|
||||
public function testMapByStatus()
|
||||
|
@ -36,7 +36,7 @@ class AnimeListTransformerTest extends AnimeClient_TestCase {
|
||||
*/
|
||||
public function testLinearizeGenres($original, $expected)
|
||||
{
|
||||
$actual = $this->transformerFriend->linearize_genres($original);
|
||||
$actual = $this->transformerFriend->linearizeGenres($original);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
@ -44,8 +44,7 @@ class AnimeListTransformerTest extends AnimeClient_TestCase {
|
||||
{
|
||||
$json = Json::decodeFile($this->start_file);
|
||||
$expected = Json::decodeFile($this->res_file);
|
||||
$actual = $this->transformer->transform_collection($json);
|
||||
//file_put_contents($this->res_file, json_encode($actual));
|
||||
$actual = $this->transformer->transformCollection($json);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ class MangaListTransformerTest extends AnimeClient_TestCase {
|
||||
$orig_json = Json::decodeFile($this->start_file);
|
||||
$expected = Json::decodeFile($this->res_file);
|
||||
|
||||
$actual = $this->transformer->transform_collection($orig_json);
|
||||
$actual = $this->transformer->transformCollection($orig_json);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ class MockBaseApiModel extends BaseApiModel {
|
||||
use MockInjectionTrait;
|
||||
protected $base_url = 'https://httpbin.org/';
|
||||
|
||||
protected function _get_list_from_api($status)
|
||||
protected function _get_list_from_api(string $status): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user