Update all the docblocks

This commit is contained in:
Timothy Warren 2019-12-09 14:34:23 -05:00
parent 75aa7e3aae
commit acd3b84b55
39 changed files with 324 additions and 157 deletions

View File

@ -30,7 +30,7 @@ use Psr\Log\LoggerAwareTrait;
/** /**
* Wrapper around Artax to make it easier to build API requests * Wrapper around Artax to make it easier to build API requests
*/ */
class APIRequestBuilder { abstract class APIRequestBuilder {
use LoggerAwareTrait; use LoggerAwareTrait;
/** /**

View File

@ -28,6 +28,9 @@ 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,6 +183,12 @@ 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);
@ -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,7 +280,7 @@ 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());
} }

View File

@ -28,6 +28,8 @@ use Aviat\Ion\Json;
use Aviat\Ion\Di\Exception\ContainerException; use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException; use Aviat\Ion\Di\Exception\NotFoundException;
use Throwable;
/** /**
* Anilist API Model * Anilist API Model
*/ */
@ -59,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
{ {

View File

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

View File

@ -18,6 +18,7 @@ namespace Aviat\AnimeClient\API\Kitsu;
use Aura\Session\Segment; 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\{
@ -25,6 +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 Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
use Throwable;
/** /**
* Kitsu API Authentication * Kitsu API Authentication
@ -51,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)
{ {
@ -67,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
{ {
@ -110,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
{ {

View File

@ -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)
{ {
@ -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
@ -241,6 +248,7 @@ trait KitsuTrait {
* 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

View File

@ -16,6 +16,8 @@
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;
@ -27,6 +29,8 @@ 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
*/ */
@ -34,6 +38,11 @@ final class ListItem implements ListItemInterface {
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();
@ -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();
@ -138,7 +163,9 @@ final class ListItem implements ListItemInterface {
} }
/** /**
* @return false|string * @return bool|string
* @throws ContainerException
* @throws NotFoundException
*/ */
private function getAuthHeader() private function getAuthHeader()
{ {

View File

@ -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)
{ {
@ -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)
{ {
@ -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,6 +867,7 @@ 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
{ {

View File

@ -44,14 +44,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'];
}); });
} }

View File

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

View File

@ -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'];
}); });
} }
@ -131,12 +131,13 @@ final class MangaTransformer extends AbstractTransformer {
} }
/** /**
* @return int|null|string * @param int|null $value
* @return string
*/ */
private function count(int $value = NULL) private function count(int $value = NULL): string
{ {
return ((int)$value === 0) return ((int)$value === 0)
? '-' ? '-'
: $value; : (string)$value;
} }
} }

View File

@ -78,7 +78,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 +103,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 +114,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'];
}); });
} }

View File

@ -41,6 +41,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))

View File

@ -21,6 +21,8 @@ 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
*/ */
@ -68,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
{ {
@ -91,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
{ {

View File

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

View File

@ -28,6 +28,8 @@ use Aviat\AnimeClient\API\Anilist\Transformer\{
}; };
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;
@ -53,8 +55,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
@ -173,8 +175,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
{ {
@ -206,8 +208,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
{ {

View File

@ -17,6 +17,7 @@
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;
@ -63,8 +64,7 @@ final class UpdateThumbnails extends ClearThumbnails {
} }
/** /**
* @return array-key[][] * @return array array-key[][]
*
* @psalm-return array{anime: list<array-key>, manga: list<array-key>} * @psalm-return array{anime: list<array-key>, manga: list<array-key>}
*/ */
public function getImageList(): array public function getImageList(): array

View File

@ -27,6 +27,9 @@ use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException; 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
*/ */
@ -65,7 +68,8 @@ final class Anime extends BaseController {
* @param string $view - List or cover view * @param string $view - List or cover view
* @throws ContainerException * @throws ContainerException
* @throws 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
@ -110,7 +114,8 @@ final class Anime extends BaseController {
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws RouteNotFound * @throws RouteNotFound
* @throws \InvalidArgumentException * @throws InvalidArgumentException
* @throws Throwable
* @return void * @return void
*/ */
public function addForm(): void public function addForm(): void
@ -133,6 +138,7 @@ final class Anime extends BaseController {
* *
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws Throwable
* @return void * @return void
*/ */
public function add(): void public function add(): void
@ -171,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
{ {
@ -209,6 +216,7 @@ final class Anime extends BaseController {
* *
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws Throwable
* @return void * @return void
*/ */
public function formUpdate(): void public function formUpdate(): void
@ -239,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
@ -269,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
@ -297,7 +307,7 @@ final class Anime extends BaseController {
* @param string $animeId * @param string $animeId
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws InvalidArgumentException
* @return void * @return void
*/ */
public function details(string $animeId): void public function details(string $animeId): void

View File

@ -27,6 +27,8 @@ use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException; use Aviat\Ion\Di\Exception\NotFoundException;
use Aviat\Ion\Exception\DoubleRenderException; use Aviat\Ion\Exception\DoubleRenderException;
use InvalidArgumentException;
/** /**
* Controller for Anime collection pages * Controller for Anime collection pages
*/ */
@ -89,7 +91,7 @@ final class AnimeCollection extends BaseController {
* @param string $view * @param string $view
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws InvalidArgumentException
* @return void * @return void
*/ */
public function view($view): void public function view($view): void
@ -115,7 +117,7 @@ final class AnimeCollection extends BaseController {
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws RouteNotFound * @throws RouteNotFound
* @throws \InvalidArgumentException * @throws InvalidArgumentException
* @return void * @return void
*/ */
public function form($id = NULL): void public function form($id = NULL): void
@ -144,7 +146,7 @@ final class AnimeCollection extends BaseController {
* *
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws InvalidArgumentException
* @return void * @return void
*/ */
public function edit(): void public function edit(): void
@ -179,7 +181,7 @@ final class AnimeCollection extends BaseController {
* *
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws \InvalidArgumentException * @throws InvalidArgumentException
* @return void * @return void
*/ */
public function add(): void public function add(): void

View File

@ -16,10 +16,13 @@
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)
{ {

View File

@ -24,6 +24,8 @@ 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
*/ */
@ -36,7 +38,7 @@ final class Images extends BaseController {
* @param bool $display Whether to output the image to the server * @param bool $display Whether to output the image to the server
* @return void * @return void
* @throws NotFoundException * @throws NotFoundException
* @throws \Throwable * @throws Throwable
* @throws ContainerException * @throws ContainerException
*/ */
public function cache(string $type, string $file, $display = TRUE): void public function cache(string $type, string $file, $display = TRUE): void

View File

@ -16,13 +16,18 @@
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

View File

@ -16,13 +16,19 @@
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

View File

@ -16,10 +16,13 @@
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)
{ {

View File

@ -16,8 +16,12 @@
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
{ {

View File

@ -16,10 +16,13 @@
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)
{ {

View File

@ -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
{ {
@ -149,8 +153,8 @@ 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
@ -161,7 +165,7 @@ final class Dispatcher extends RoutingBase {
} }
else else
{ {
throw new \LogicException('Missing controller'); 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
@ -249,7 +253,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 +300,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
*/ */

View File

@ -16,7 +16,10 @@
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)
{ {

View File

@ -16,11 +16,12 @@
namespace Aviat\AnimeClient; namespace Aviat\AnimeClient;
use Aviat\Ion\{ use Aviat\Ion\{ArrayWrapper, StringWrapper};
ArrayWrapper, StringWrapper use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
}; use Aura\Html\HelperLocator;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Exception\ConfigException; use Aviat\Ion\Exception\ConfigException;
use Psr\Http\Message\RequestInterface;
/** /**
* Helper object to manage menu creation and selection * Helper object to manage menu creation and selection
@ -33,14 +34,14 @@ final class MenuGenerator extends UrlGenerator {
/** /**
* Html generation helper * Html generation helper
* *
* @var \Aura\Html\HelperLocator * @var HelperLocator
*/ */
protected $helper; protected $helper;
/** /**
* Request object * Request object
* *
* @var \Psr\Http\Message\RequestInterface * @var RequestInterface
*/ */
protected $request; protected $request;
@ -48,8 +49,8 @@ final class MenuGenerator extends UrlGenerator {
* MenuGenerator constructor. * MenuGenerator 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)
{ {

View File

@ -28,6 +28,8 @@ use Aviat\AnimeClient\Types\{
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Json; use Aviat\Ion\Json;
use Throwable;
/** /**
* Model for handling requests dealing with the anime list * Model for handling requests dealing with the anime list
*/ */
@ -162,6 +164,7 @@ class Anime extends API {
* *
* @param array $data * @param array $data
* @return bool * @return bool
* @throws Throwable
*/ */
public function createLibraryItem(array $data): bool public function createLibraryItem(array $data): bool
{ {
@ -183,6 +186,7 @@ class Anime extends API {
* *
* @param FormItem $data * @param FormItem $data
* @return array * @return array
* @throws Throwable
*/ */
public function incrementLibraryItem(FormItem $data): array public function incrementLibraryItem(FormItem $data): array
{ {
@ -210,6 +214,7 @@ class Anime extends API {
* *
* @param FormItem $data * @param FormItem $data
* @return array * @return array
* @throws Throwable
*/ */
public function updateLibraryItem(FormItem $data): array public function updateLibraryItem(FormItem $data): array
{ {
@ -238,6 +243,7 @@ class Anime extends API {
* @param string $id * @param string $id
* @param string|null $malId * @param string|null $malId
* @return bool * @return bool
* @throws Throwable
*/ */
public function deleteLibraryItem(string $id, string $malId = NULL): bool public function deleteLibraryItem(string $id, string $malId = NULL): bool
{ {

View File

@ -21,7 +21,7 @@ use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
/** /**
* Base model for database interaction * Base model for database interaction
*/ */
class DB { abstract class DB {
use ContainerAware; use ContainerAware;
/** /**

View File

@ -29,6 +29,8 @@ use Aviat\AnimeClient\Types\{
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Json; use Aviat\Ion\Json;
use Throwable;
/** /**
* Model for handling requests dealing with the manga list * Model for handling requests dealing with the manga list
*/ */
@ -130,6 +132,7 @@ class Manga extends API {
* *
* @param array $data * @param array $data
* @return bool * @return bool
* @throws Throwable
*/ */
public function createLibraryItem(array $data): bool public function createLibraryItem(array $data): bool
{ {
@ -151,6 +154,7 @@ class Manga extends API {
* *
* @param FormItem $data * @param FormItem $data
* @return array * @return array
* @throws Throwable
*/ */
public function updateLibraryItem(FormItem $data): array public function updateLibraryItem(FormItem $data): array
{ {
@ -179,6 +183,7 @@ class Manga extends API {
* *
* @param FormItem $data * @param FormItem $data
* @return array * @return array
* @throws Throwable
*/ */
public function incrementLibraryItem(FormItem $data): array public function incrementLibraryItem(FormItem $data): array
{ {
@ -208,6 +213,7 @@ class Manga extends API {
* @param string $id * @param string $id
* @param string|null $malId * @param string|null $malId
* @return bool * @return bool
* @throws Throwable
*/ */
public function deleteLibraryItem(string $id, string $malId = NULL): bool public function deleteLibraryItem(string $id, string $malId = NULL): bool
{ {

View File

@ -16,8 +16,13 @@
namespace Aviat\AnimeClient; namespace Aviat\AnimeClient;
use Aviat\Ion\Config;
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\ConfigException;
use Aviat\Ion\StringWrapper; use Aviat\Ion\StringWrapper;
use Psr\Http\Message\ServerRequestInterface;
/** /**
* Base for routing/url classes * Base for routing/url classes
@ -34,13 +39,13 @@ class RoutingBase {
/** /**
* Config Object * Config Object
* @var \Aviat\Ion\Config * @var Config
*/ */
protected $config; protected $config;
/** /**
* Class wrapper for input superglobals * Class wrapper for input superglobals
* @var \Psr\Http\Message\ServerRequestInterface * @var ServerRequestInterface
*/ */
protected $request; protected $request;
@ -48,9 +53,9 @@ class RoutingBase {
* Constructor * Constructor
* *
* @param ContainerInterface $container * @param ContainerInterface $container
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @throws \Aviat\Ion\Exception\ConfigException * @throws ConfigException
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -61,8 +66,8 @@ class RoutingBase {
/** /**
* Get the current url path * Get the current url path
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return string * @return string
*/ */
public function path(): string public function path(): string
@ -79,8 +84,8 @@ class RoutingBase {
/** /**
* Get the url segments * Get the url segments
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return array * @return array
*/ */
public function segments(): array public function segments(): array
@ -93,8 +98,8 @@ class RoutingBase {
* Get a segment of the current url * Get a segment of the current url
* *
* @param int $num * @param int $num
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return string|null * @return string|null
*/ */
public function getSegment($num): ?string public function getSegment($num): ?string
@ -106,8 +111,8 @@ class RoutingBase {
/** /**
* Retrieve the last url segment * Retrieve the last url segment
* *
* @throws \Aviat\Ion\Di\ContainerException * @throws ContainerException
* @throws \Aviat\Ion\Di\NotFoundException * @throws NotFoundException
* @return string * @return string
*/ */
public function lastSegment(): string public function lastSegment(): string

View File

@ -17,7 +17,6 @@
namespace Aviat\AnimeClient\Types; namespace Aviat\AnimeClient\Types;
use ArrayAccess; use ArrayAccess;
use ArrayObject;
use Countable; use Countable;
abstract class AbstractType implements ArrayAccess, Countable { abstract class AbstractType implements ArrayAccess, Countable {

View File

@ -33,11 +33,4 @@ class Cache extends AbstractType {
* @var array * @var array
*/ */
public $options = []; public $options = [];
/* public function setConnection($data): void
{
$this->connection = new class($data) extends AbstractType {
};
} */
} }

View File

@ -59,5 +59,11 @@ class FormItemData extends AbstractType {
* @var string * @var string
*/ */
public $status; public $status;
/**
* W3C Format Date string
*
* @var string
*/
public $updatedAt; public $updatedAt;
} }

View File

@ -17,6 +17,8 @@
namespace Aviat\AnimeClient; namespace Aviat\AnimeClient;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\ContainerException;
use Aviat\Ion\Di\Exception\NotFoundException;
use InvalidArgumentException; use InvalidArgumentException;
/** /**
@ -34,8 +36,8 @@ class UrlGenerator extends RoutingBase {
* Constructor * 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)
{ {
@ -47,7 +49,7 @@ class UrlGenerator extends RoutingBase {
/** /**
* Get the base url for css/js/images * Get the base url for css/js/images
* *
* @param string[] $args * @param string ...$args
* @return string * @return string
*/ */
public function assetUrl(string ...$args): string public function assetUrl(string ...$args): string

View File

@ -163,12 +163,6 @@ const SETTINGS_MAP = [
'Dark Theme' => 'dark', 'Dark Theme' => 'dark',
] ]
], ],
/* 'dark_theme' => [
'type' => 'boolean',
'title' => 'Use Dark Theme',
'default' => FALSE,
'description' => 'Use a darker background theme?',
],*/
'show_anime_collection' => [ 'show_anime_collection' => [
'type' => 'boolean', 'type' => 'boolean',
'title' => 'Show Anime Collection', 'title' => 'Show Anime Collection',

View File

@ -20,19 +20,24 @@ use Aviat\AnimeClient\Command\BaseCommand;
use Aviat\AnimeClient\Tests\AnimeClientTestCase; use Aviat\AnimeClient\Tests\AnimeClientTestCase;
use Aviat\Ion\Friend; use Aviat\Ion\Friend;
use ConsoleKit\Console; use ConsoleKit\Console;
use Aviat\Ion\Di\Container;
class Command extends BaseCommand {
}
class BaseCommandTest extends AnimeClientTestCase { class BaseCommandTest extends AnimeClientTestCase {
protected $base; protected $base;
protected $friend; protected $friend;
public function setUp(): void { public function setUp(): void {
$this->base = new BaseCommand(new Console()); $this->base = new Command(new Console());
$this->friend = new Friend($this->base); $this->friend = new Friend($this->base);
} }
public function testSetupContainer() public function testSetupContainer(): void
{ {
$container = $this->friend->setupContainer(); $container = $this->friend->setupContainer();
$this->assertInstanceOf('Aviat\Ion\Di\Container', $container); $this->assertInstanceOf(Container::class, $container);
} }
} }