Code style improvements
This commit is contained in:
parent
4532bd1865
commit
231babe218
@ -26,7 +26,7 @@ $ROOT_DIR = realpath("{$APP_DIR}/../");
|
||||
|
||||
$tomlConfig = loadToml(__DIR__);
|
||||
|
||||
$base_config = array_merge($tomlConfig, [
|
||||
return array_merge($tomlConfig, [
|
||||
'asset_dir' => "{$ROOT_DIR}/public",
|
||||
|
||||
// Template file path
|
||||
|
@ -36,7 +36,7 @@ use Zend\Diactoros\{Response, ServerRequestFactory};
|
||||
// -----------------------------------------------------------------------------
|
||||
// Setup DI container
|
||||
// -----------------------------------------------------------------------------
|
||||
return function(array $configArray = []) {
|
||||
return function (array $configArray = []) {
|
||||
$container = new Container();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -49,7 +49,7 @@ return function(array $configArray = []) {
|
||||
$kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE));
|
||||
$malRequestLogger = new Logger('mal-request');
|
||||
$malRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/mal_request.log', Logger::NOTICE));
|
||||
$container->setLogger($appLogger, 'default');
|
||||
$container->setLogger($appLogger);
|
||||
$container->setLogger($kitsuRequestLogger, 'kitsu-request');
|
||||
$container->setLogger($malRequestLogger, 'mal-request');
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
"clean": "vendor/bin/robo clean",
|
||||
"coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build",
|
||||
"docs": "vendor/bin/phpdox",
|
||||
"phpstan": "phpstan analyse src tests",
|
||||
"phpstan": "phpstan analyse -l 3 ./phpstan.neon src tests",
|
||||
"watch:css": "cd public && npm run watch",
|
||||
"test": "vendor/bin/phpunit"
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ $CONF_DIR = _dir($APP_DIR, 'config');
|
||||
// -----------------------------------------------------------------------------
|
||||
// Dependency Injection setup
|
||||
// -----------------------------------------------------------------------------
|
||||
require_once $APPCONF_DIR . '/base_config.php'; // $base_config
|
||||
$di = require $APP_DIR . '/bootstrap.php';
|
||||
$base_config = require $APPCONF_DIR . '/base_config.php';
|
||||
$di = require_once $APP_DIR . '/bootstrap.php';
|
||||
|
||||
$config = loadToml($CONF_DIR);
|
||||
$config_array = array_merge($base_config, $config);
|
||||
|
7
phpstan.neon
Normal file
7
phpstan.neon
Normal file
@ -0,0 +1,7 @@
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
- '#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 Aura\\\Html\\\HelperLocator:[a-zA-Z0-9_]+\(\)#'
|
||||
excludes_analyze:
|
||||
- %rootDir%/test_views/*
|
@ -30,15 +30,7 @@ use Amp\{
|
||||
TimeoutCancellationToken
|
||||
};
|
||||
use Amp\Artax\{
|
||||
ConnectionInfo,
|
||||
Client,
|
||||
HttpException,
|
||||
HttpSocketPool,
|
||||
MetaInfo,
|
||||
Response,
|
||||
Request,
|
||||
TimeoutException,
|
||||
TlsInfo
|
||||
ConnectionInfo, Client, DnsException, HttpException, HttpSocketPool, MetaInfo, ParseException, RequestBody, Response, Request, SocketException, TimeoutException, TlsInfo, TooManyRedirectsException
|
||||
};
|
||||
use Amp\Artax\Cookie\{
|
||||
Cookie,
|
||||
|
@ -44,7 +44,7 @@ class JsonAPI {
|
||||
* Inline all included data
|
||||
*
|
||||
* @param array $data - The raw JsonAPI response data
|
||||
* @return data
|
||||
* @return array
|
||||
*/
|
||||
public static function organizeData(array $data): array
|
||||
{
|
||||
@ -54,7 +54,7 @@ class JsonAPI {
|
||||
];
|
||||
|
||||
// Reorganize included data
|
||||
$included = (array_key_exists('included', $data))
|
||||
$included = array_key_exists('included', $data)
|
||||
? static::organizeIncluded($data['included'])
|
||||
: [];
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Model {
|
||||
]
|
||||
]);
|
||||
$data = Json::decode(wait($response->getBody()));
|
||||
|
||||
|
||||
//dump($response);
|
||||
|
||||
if (array_key_exists('access_token', $data))
|
||||
@ -763,7 +763,7 @@ class Model {
|
||||
* Get the mal id for the manga represented by the kitsu id
|
||||
* to enable updating MyAnimeList
|
||||
*
|
||||
* @param string $kitsuAnimeId The id of the anime on Kitsu
|
||||
* @param string $kitsuMangaId The id of the manga on Kitsu
|
||||
* @return string|null Returns the mal id if it exists, otherwise null
|
||||
*/
|
||||
public function getMalIdForManga(string $kitsuMangaId)
|
||||
|
@ -27,7 +27,7 @@ interface ListItemInterface {
|
||||
* Create a list item
|
||||
*
|
||||
* @param array $data -
|
||||
* @return bool
|
||||
* @return Request
|
||||
*/
|
||||
public function create(array $data): Request;
|
||||
|
||||
@ -44,7 +44,7 @@ interface ListItemInterface {
|
||||
*
|
||||
* @param string $id - The id of the list item to update
|
||||
* @param array $data - The data with which to update the list item
|
||||
* @return Response
|
||||
* @return Request
|
||||
*/
|
||||
public function update(string $id, array $data): Request;
|
||||
|
||||
@ -52,7 +52,7 @@ interface ListItemInterface {
|
||||
* Delete a list item
|
||||
*
|
||||
* @param string $id - The id of the list item to delete
|
||||
* @return bool
|
||||
* @return Request
|
||||
*/
|
||||
public function delete(string $id): Request;
|
||||
}
|
@ -38,6 +38,11 @@ class Model {
|
||||
*/
|
||||
protected $animeListTransformer;
|
||||
|
||||
/**
|
||||
* @var MangaListTransformer
|
||||
*/
|
||||
protected $mangaListTransformer;
|
||||
|
||||
/**
|
||||
* @var ListItem
|
||||
*/
|
||||
@ -76,6 +81,8 @@ class Model {
|
||||
*/
|
||||
public function createListItem(array $data, string $type = 'anime'): Request
|
||||
{
|
||||
$createData = [];
|
||||
|
||||
if ($type === 'anime')
|
||||
{
|
||||
$createData = [
|
||||
@ -119,7 +126,7 @@ class Model {
|
||||
]
|
||||
]);
|
||||
|
||||
return (array_key_exists($type, $list['myanimelist']))
|
||||
return array_key_exists($type, $list['myanimelist'])
|
||||
? $list['myanimelist'][$type]
|
||||
: [];
|
||||
}
|
||||
@ -146,6 +153,8 @@ class Model {
|
||||
*/
|
||||
public function updateListItem(array $data, string $type = 'anime'): Request
|
||||
{
|
||||
$updateData = [];
|
||||
|
||||
if ($type === 'anime')
|
||||
{
|
||||
$updateData = $this->animeListTransformer->untransform($data);
|
||||
|
@ -34,7 +34,7 @@ class ParallelAPIRequest {
|
||||
/**
|
||||
* Add a request
|
||||
*
|
||||
* @param string|Request $request
|
||||
* @param string|\Amp\Artax\Request $request
|
||||
* @param string|number $key
|
||||
* @return self
|
||||
*/
|
||||
@ -53,7 +53,7 @@ class ParallelAPIRequest {
|
||||
/**
|
||||
* Add multiple requests
|
||||
*
|
||||
* @param string[]|Request[] $requests
|
||||
* @param string[]|\Amp\Artax\Request[] $requests
|
||||
* @return self
|
||||
*/
|
||||
public function addRequests(array $requests): self
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace Aviat\AnimeClient\API;
|
||||
|
||||
use DOMDocument, DOMNode, DOMNodelist;
|
||||
use DOMDocument, DOMNode, DOMNodeList;
|
||||
|
||||
/**
|
||||
* XML <=> PHP Array codec
|
||||
@ -180,7 +180,7 @@ class XML {
|
||||
// except for the xml declaration tag, Which looks
|
||||
// something like:
|
||||
/* <?xml version="1.0" encoding="UTF-8"?> */
|
||||
|
||||
|
||||
return preg_replace('/([^\?])>\s+</', '$1><', $xml);
|
||||
}
|
||||
|
||||
|
@ -18,15 +18,15 @@ namespace Aviat\AnimeClient;
|
||||
|
||||
use Yosymfony\Toml\Toml;
|
||||
|
||||
if ( ! defined('SRC_DIR'))
|
||||
if ( ! \defined('SRC_DIR'))
|
||||
{
|
||||
\define('SRC_DIR', \realpath(__DIR__));
|
||||
}
|
||||
|
||||
const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth';
|
||||
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Index';
|
||||
const DEFAULT_CONTROLLER_NAMESPACE = 'Aviat\AnimeClient\Controller';
|
||||
const DEFAULT_LIST_CONTROLLER = 'Aviat\AnimeClient\Controller\Anime';
|
||||
const DEFAULT_CONTROLLER = Controller\Index::class;
|
||||
const DEFAULT_CONTROLLER_NAMESPACE = Controller::class;
|
||||
const DEFAULT_LIST_CONTROLLER = Controller\Anime::class;
|
||||
const DEFAULT_CONTROLLER_METHOD = 'index';
|
||||
const NOT_FOUND_METHOD = 'notFound';
|
||||
const ERROR_MESSAGE_METHOD = 'errorPage';
|
||||
|
@ -19,11 +19,7 @@ namespace Aviat\AnimeClient\Command;
|
||||
use function Aviat\AnimeClient\loadToml;
|
||||
|
||||
use Aura\Session\SessionFactory;
|
||||
use Aviat\AnimeClient\{
|
||||
AnimeClient,
|
||||
Model,
|
||||
Util
|
||||
};
|
||||
use Aviat\AnimeClient\Util;
|
||||
use Aviat\AnimeClient\API\CacheTrait;
|
||||
use Aviat\AnimeClient\API\{Kitsu, MAL};
|
||||
use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
|
||||
@ -67,7 +63,7 @@ class BaseCommand extends Command {
|
||||
$APP_DIR = realpath(__DIR__ . '/../../app');
|
||||
$APPCONF_DIR = realpath("{$APP_DIR}/appConf/");
|
||||
$CONF_DIR = realpath("{$APP_DIR}/config/");
|
||||
require_once $APPCONF_DIR . '/base_config.php'; // $base_config
|
||||
$base_config = require_once $APPCONF_DIR . '/base_config.php';
|
||||
|
||||
$config = loadToml($CONF_DIR);
|
||||
$config_array = array_merge($base_config, $config);
|
||||
@ -85,7 +81,7 @@ class BaseCommand extends Command {
|
||||
$kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE));
|
||||
$mal_request_logger = new Logger('mal-request');
|
||||
$mal_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/mal_request-cli.log', Logger::NOTICE));
|
||||
$container->setLogger($app_logger, 'default');
|
||||
$container->setLogger($app_logger);
|
||||
$container->setLogger($kitsu_request_logger, 'kitsu-request');
|
||||
$container->setLogger($mal_request_logger, 'mal-request');
|
||||
|
||||
|
@ -51,7 +51,6 @@ class SyncKitsuWithMal extends BaseCommand {
|
||||
* @param array $args
|
||||
* @param array $options
|
||||
* @return void
|
||||
* @throws \ConsoleKit\ConsoleException
|
||||
*/
|
||||
public function execute(array $args, array $options = [])
|
||||
{
|
||||
@ -80,6 +79,7 @@ class SyncKitsuWithMal extends BaseCommand {
|
||||
);
|
||||
}
|
||||
|
||||
$kitsuCount = 0;
|
||||
try
|
||||
{
|
||||
$kitsuCount = $this->kitsuModel->{"get{$uType}ListCount"}();
|
||||
|
@ -18,15 +18,20 @@ namespace Aviat\AnimeClient;
|
||||
|
||||
use function Aviat\Ion\_dir;
|
||||
|
||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||
use Aviat\Ion\Di\{
|
||||
ContainerAware,
|
||||
ContainerInterface
|
||||
};
|
||||
use Aviat\Ion\Di\Exception\{
|
||||
ContainerException,
|
||||
NotFoundException
|
||||
};
|
||||
use Aviat\Ion\Exception\DoubleRenderException;
|
||||
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Controller base, defines output methods
|
||||
*
|
||||
* @property $response Response object
|
||||
*/
|
||||
class Controller {
|
||||
|
||||
@ -46,22 +51,16 @@ class Controller {
|
||||
|
||||
/**
|
||||
* Request object
|
||||
* @var object $request
|
||||
* @var \Psr\Http\Message\ServerRequestInterface $request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response object
|
||||
* @var object $response
|
||||
* @var \Psr\Http\Message\ResponseInterface $response
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* The api model for the current controller
|
||||
* @var object
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Url generation class
|
||||
* @var UrlGenerator
|
||||
@ -94,8 +93,8 @@ class Controller {
|
||||
* Constructor
|
||||
*
|
||||
* @param ContainerInterface $container
|
||||
* @throws \Aviat\Ion\Di\ContainerException
|
||||
* @throws \Aviat\Ion\Di\NotFoundException
|
||||
* @throws ContainerException
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
@ -146,8 +145,8 @@ class Controller {
|
||||
* Set the current url in the session as the target of a future redirect
|
||||
*
|
||||
* @param string|null $url
|
||||
* @throws \Aviat\Ion\Di\ContainerException
|
||||
* @throws \Aviat\Ion\Di\NotFoundException
|
||||
* @throws ContainerException
|
||||
* @throws NotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function setSessionRedirect(string $url = NULL)
|
||||
@ -174,7 +173,7 @@ class Controller {
|
||||
if (null === $url)
|
||||
{
|
||||
$url = $util->isViewPage()
|
||||
? $this->request->url->get()
|
||||
? $this->request->getUri()->__toString()
|
||||
: $serverParams['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,8 @@
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use Aviat\AnimeClient\Controller as BaseController;
|
||||
use Aviat\AnimeClient\API\Kitsu\{
|
||||
Enum\AnimeWatchingStatus as KitsuWatchingStatus,
|
||||
Transformer\AnimeListTransformer
|
||||
};
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
|
||||
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Kitsu as KitsuWatchingStatus;
|
||||
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Json;
|
||||
@ -35,22 +33,10 @@ class Anime extends BaseController {
|
||||
|
||||
/**
|
||||
* The anime list model
|
||||
* @var object $model
|
||||
* @var \Aviat\AnimeClient\Model\Anime $model
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Data to be sent to all routes in this controller
|
||||
* @var array $baseData
|
||||
*/
|
||||
protected $baseData;
|
||||
|
||||
/**
|
||||
* Data cache
|
||||
* @var \Psr\Cache\CachePoolInterface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -158,7 +144,7 @@ class Anime extends BaseController {
|
||||
*/
|
||||
public function edit($id, $status = "all")
|
||||
{
|
||||
$item = $this->model->getLibraryItem($id, $status);
|
||||
$item = $this->model->getLibraryItem($id);
|
||||
$this->setSessionRedirect();
|
||||
|
||||
$this->outputHTML('anime/edit', [
|
||||
@ -203,7 +189,7 @@ class Anime extends BaseController {
|
||||
|
||||
if ($fullResult['statusCode'] === 200)
|
||||
{
|
||||
$this->setFlashMessage("Successfully updated.", 'success');
|
||||
$this->setFlashMessage('Successfully updated.', 'success');
|
||||
$this->cache->clear();
|
||||
}
|
||||
else
|
||||
@ -230,7 +216,7 @@ class Anime extends BaseController {
|
||||
$data = $this->request->getParsedBody();
|
||||
}
|
||||
|
||||
$response = $this->model->updateLibraryItem($data, $data);
|
||||
$response = $this->model->updateLibraryItem($data);
|
||||
|
||||
$this->cache->clear();
|
||||
$this->outputJSON($response['body'], $response['statusCode']);
|
||||
@ -272,12 +258,14 @@ class Anime extends BaseController {
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
return $this->notFound(
|
||||
$this->notFound(
|
||||
$this->config->get('whose_list') .
|
||||
"'s Anime List · Anime · " .
|
||||
'Anime not found',
|
||||
'Anime Not Found'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_key_exists('characters', $data['included']))
|
||||
|
@ -35,13 +35,15 @@ class Character extends BaseController {
|
||||
|
||||
if (( ! array_key_exists('data', $rawData)) || empty($rawData['data']))
|
||||
{
|
||||
return $this->notFound(
|
||||
$this->notFound(
|
||||
$this->formatTitle(
|
||||
'Characters',
|
||||
'Character not found'
|
||||
),
|
||||
'Character Not Found'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$data = JsonAPI::organizeData($rawData);
|
||||
@ -110,22 +112,22 @@ class Character extends BaseController {
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
private function getCastCount(array $cast): int
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
|
||||
foreach($cast as $role)
|
||||
{
|
||||
if (
|
||||
array_key_exists('attributes', $role) &&
|
||||
array_key_exists('attributes', $role) &&
|
||||
array_key_exists('role', $role['attributes']) &&
|
||||
( ! is_null($role['attributes']['role']))
|
||||
) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
@ -265,12 +265,13 @@ class Manga extends Controller {
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
return $this->notFound(
|
||||
$this->notFound(
|
||||
$this->config->get('whose_list') .
|
||||
"'s Manga List · Manga · " .
|
||||
'Manga not found',
|
||||
'Manga Not Found'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($data['included'] as $included)
|
||||
|
@ -18,8 +18,8 @@ namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use Aviat\AnimeClient\Controller as BaseController;
|
||||
use Aviat\AnimeClient\Model\{
|
||||
manga as mangaModel,
|
||||
mangaCollection as mangaCollectionModel
|
||||
Manga as MangaModel,
|
||||
MangaCollection as MangaCollectionModel
|
||||
};
|
||||
use Aviat\AnimeClient\UrlGenerator;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
@ -31,13 +31,13 @@ class MangaCollection extends BaseController {
|
||||
|
||||
/**
|
||||
* The manga collection model
|
||||
* @var mangaCollectionModel $mangaCollectionModel
|
||||
* @var MangaCollectionModel $mangaCollectionModel
|
||||
*/
|
||||
private $mangaCollectionModel;
|
||||
|
||||
/**
|
||||
* The manga API model
|
||||
* @var mangaModel $mangaModel
|
||||
* @var MangaModel $mangaModel
|
||||
*/
|
||||
private $mangaModel;
|
||||
|
||||
|
@ -18,6 +18,8 @@ namespace Aviat\AnimeClient;
|
||||
|
||||
use function Aviat\Ion\_dir;
|
||||
|
||||
use Aura\Router\Matcher;
|
||||
|
||||
use Aviat\AnimeClient\API\FailedResponseException;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Friend;
|
||||
@ -38,7 +40,7 @@ class Dispatcher extends RoutingBase {
|
||||
|
||||
/**
|
||||
* The route matcher
|
||||
* @var object $matcher
|
||||
* @var Matcher $matcher
|
||||
*/
|
||||
protected $matcher;
|
||||
|
||||
@ -72,14 +74,14 @@ class Dispatcher extends RoutingBase {
|
||||
/**
|
||||
* Get the current route object, if one matches
|
||||
*
|
||||
* @return object
|
||||
* @return \Aura\Router\Route|false
|
||||
*/
|
||||
public function getRoute()
|
||||
{
|
||||
$logger = $this->container->getLogger('default');
|
||||
|
||||
$rawRoute = $this->request->getUri()->getPath();
|
||||
$routePath = "/" . trim($rawRoute, '/');
|
||||
$routePath = '/' . trim($rawRoute, '/');
|
||||
|
||||
$logger->info('Dispatcher - Routing data from get_route method');
|
||||
$logger->info(print_r([
|
||||
|
@ -16,8 +16,11 @@
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\{ArrayWrapper, StringWrapper};
|
||||
use Aviat\Ion\{
|
||||
ArrayWrapper, StringWrapper
|
||||
};
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Exception\ConfigException;
|
||||
|
||||
/**
|
||||
* Helper object to manage menu creation and selection
|
||||
@ -80,6 +83,7 @@ class MenuGenerator extends UrlGenerator {
|
||||
* Generate the html structure of the menu selected
|
||||
*
|
||||
* @param string $menu
|
||||
* @throws ConfigException
|
||||
* @return string
|
||||
*/
|
||||
public function generate($menu)
|
||||
|
@ -28,7 +28,7 @@ class AnimeCollection extends Collection {
|
||||
|
||||
/**
|
||||
* Anime API Model
|
||||
* @var object $animeModel
|
||||
* @var Anime $animeModel
|
||||
*/
|
||||
protected $animeModel;
|
||||
|
||||
@ -221,7 +221,7 @@ class AnimeCollection extends Collection {
|
||||
private function updateGenre($animeId)
|
||||
{
|
||||
$genreInfo = $this->getGenreData();
|
||||
extract($genreInfo);
|
||||
extract($genreInfo, \EXTR_SKIP);
|
||||
|
||||
// Get api information
|
||||
$anime = $this->animeModel->getAnimeById($animeId);
|
||||
|
@ -26,7 +26,7 @@ class DB extends AbstractModel {
|
||||
|
||||
/**
|
||||
* The query builder object
|
||||
* @var object $db
|
||||
* @var \Query\Query_Builder_Interface $db
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
|
@ -28,7 +28,7 @@ class MangaCollection extends Collection {
|
||||
|
||||
/**
|
||||
* Manga API Model
|
||||
* @var object $mangaModel
|
||||
* @var Manga $mangaModel
|
||||
*/
|
||||
protected $mangaModel;
|
||||
|
||||
@ -221,12 +221,12 @@ class MangaCollection extends Collection {
|
||||
private function updateGenre($mangaId)
|
||||
{
|
||||
$genreInfo = $this->getGenreData();
|
||||
extract($genreInfo);
|
||||
extract($genreInfo, EXTR_SKIP);
|
||||
|
||||
// Get api information
|
||||
$manga = $this->mangaModel->getMangaById($mangaId);
|
||||
|
||||
foreach ($anime['genres'] as $genre)
|
||||
foreach ($manga['genres'] as $genre)
|
||||
{
|
||||
// Add genres that don't currently exist
|
||||
if ( ! in_array($genre, $genres))
|
||||
|
@ -116,7 +116,7 @@ class APIRequestBuilderTest extends TestCase {
|
||||
'foo' => [
|
||||
'bar' => 1,
|
||||
'baz' => [2, 3, 4],
|
||||
'bar' => [
|
||||
'bazbar' => [
|
||||
'a' => 1,
|
||||
'b' => 2
|
||||
]
|
||||
|
@ -20,21 +20,24 @@ use Aviat\AnimeClient\API\CacheTrait;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
|
||||
class CacheTraitTest extends AnimeClientTestCase {
|
||||
|
||||
protected $testClass;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->testClass = new class {
|
||||
use CacheTrait;
|
||||
$this->testClass = new class {
|
||||
use CacheTrait;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function testSetGet()
|
||||
{
|
||||
$cachePool = $this->container->get('cache');
|
||||
$this->testClass->setCache($cachePool);
|
||||
$this->assertEquals($cachePool, $this->testClass->getCache());
|
||||
}
|
||||
|
||||
|
||||
public function testGetHashForMethodCall()
|
||||
{
|
||||
$hash = $this->testClass->getHashForMethodCall($this, __METHOD__, []);
|
||||
|
@ -16,32 +16,34 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Tests\API;
|
||||
|
||||
use Aviat\AnimeClient\API\{APIRequestBuilder, ParallelAPIRequest};
|
||||
use Aviat\AnimeClient\API\ParallelAPIRequest;
|
||||
use Aviat\Ion\Friend;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParallelAPIRequestTest extends TestCase {
|
||||
|
||||
|
||||
public function testAddStringUrlRequest()
|
||||
{
|
||||
$requester = new ParallelAPIRequest();
|
||||
$requester->addRequest('https://httpbin.org');
|
||||
|
||||
$friend = new Friend($requester);
|
||||
$friend->addRequest('https://httpbin.org');
|
||||
|
||||
|
||||
$this->assertEquals($friend->requests, ['https://httpbin.org']);
|
||||
}
|
||||
|
||||
|
||||
public function testAddStringUrlRequests()
|
||||
{
|
||||
$requests = [
|
||||
'foo' => 'http://example.com',
|
||||
'bar' => 'https://example.com'
|
||||
];
|
||||
|
||||
|
||||
$requester = new ParallelAPIRequest();
|
||||
$requester->addRequests($requests);
|
||||
|
||||
$friend = new Friend($requester);
|
||||
$friend->addRequests($requests);
|
||||
|
||||
|
||||
$this->assertEquals($friend->requests, $requests);
|
||||
}
|
||||
}
|
@ -180,14 +180,6 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'action' => ['login'],
|
||||
'verb' => 'get'
|
||||
],
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301'
|
||||
]
|
||||
],
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
|
@ -33,7 +33,7 @@ class MenuGeneratorTest extends AnimeClientTestCase {
|
||||
public function testSanity()
|
||||
{
|
||||
$generator = new MenuGenerator($this->container);
|
||||
$this->assertInstanceOf('Aviat\AnimeClient\MenuGenerator', $generator);
|
||||
$this->assertInstanceOf(MenuGenerator::class, $generator);
|
||||
}
|
||||
|
||||
public function testParseConfig()
|
||||
|
@ -14,8 +14,8 @@ if ($timezone === '' || $timezone === FALSE)
|
||||
// Autoloading
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
require __DIR__ . '/AnimeClientTestCase.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/AnimeClientTestCase.php';
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Ini Settings
|
||||
@ -35,7 +35,7 @@ $_SESSION = [];
|
||||
$_COOKIE = [];
|
||||
|
||||
// Request base test case and mocks
|
||||
require __DIR__ . '/TestSessionHandler.php';
|
||||
require __DIR__ . '/mocks.php';
|
||||
require_once __DIR__ . '/TestSessionHandler.php';
|
||||
require_once __DIR__ . '/mocks.php';
|
||||
|
||||
// End of bootstrap.php
|
Loading…
Reference in New Issue
Block a user