Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
6 changed files with 19 additions and 25 deletions
Showing only changes of commit fdd7f91835 - Show all commits

View File

@ -65,7 +65,7 @@ trait KitsuTrait {
->get('session') ->get('session')
->getSegment(SESSION_SEGMENT); ->getSegment(SESSION_SEGMENT);
if ($sessionSegment->get('auth_token') !== null && $url !== K::AUTH_URL) if ($sessionSegment->get('auth_token') !== NULL && $url !== K::AUTH_URL)
{ {
$token = $sessionSegment->get('auth_token'); $token = $sessionSegment->get('auth_token');
$request = $request->setAuth('bearer', $token); $request = $request->setAuth('bearer', $token);
@ -104,14 +104,6 @@ trait KitsuTrait {
$response = wait((new Client)->request($request)); $response = wait((new Client)->request($request));
/* $logger->debug('Kitsu api response', [
'status' => $response->getStatus(),
'reason' => $response->getReason(),
'body' => $response->getBody(),
'headers' => $response->getAllHeaders(),
'requestHeaders' => $request->getAllHeaders(),
]); */
return $response; return $response;
} }
@ -125,7 +117,7 @@ trait KitsuTrait {
*/ */
private function request(string $type, string $url, array $options = []): array private function request(string $type, string $url, array $options = []): array
{ {
$logger = null; $logger = NULL;
if ($this->getContainer()) if ($this->getContainer())
{ {
$logger = $this->container->getLogger('kitsu-request'); $logger = $this->container->getLogger('kitsu-request');
@ -133,7 +125,7 @@ trait KitsuTrait {
$response = $this->getResponse($type, $url, $options); $response = $this->getResponse($type, $url, $options);
if ((int) $response->getStatus() > 299 || (int) $response->getStatus() < 200) if ((int) $response->getStatus() > 299 OR (int) $response->getStatus() < 200)
{ {
if ($logger) if ($logger)
{ {
@ -147,7 +139,7 @@ trait KitsuTrait {
/** /**
* Remove some boilerplate for get requests * Remove some boilerplate for get requests
* *
* @param array $args * @param mixed ...$args
* @return array * @return array
*/ */
protected function getRequest(...$args): array protected function getRequest(...$args): array
@ -158,7 +150,7 @@ trait KitsuTrait {
/** /**
* Remove some boilerplate for patch requests * Remove some boilerplate for patch requests
* *
* @param array $args * @param mixed ...$args
* @return array * @return array
*/ */
protected function patchRequest(...$args): array protected function patchRequest(...$args): array
@ -169,12 +161,12 @@ trait KitsuTrait {
/** /**
* Remove some boilerplate for post requests * Remove some boilerplate for post requests
* *
* @param array $args * @param mixed ...$args
* @return array * @return array
*/ */
protected function postRequest(...$args): array protected function postRequest(...$args): array
{ {
$logger = null; $logger = NULL;
if ($this->getContainer()) if ($this->getContainer())
{ {
$logger = $this->container->getLogger('kitsu-request'); $logger = $this->container->getLogger('kitsu-request');
@ -197,7 +189,7 @@ trait KitsuTrait {
/** /**
* Remove some boilerplate for delete requests * Remove some boilerplate for delete requests
* *
* @param array $args * @param mixed ...$args
* @return bool * @return bool
*/ */
protected function deleteRequest(...$args): bool protected function deleteRequest(...$args): bool

View File

@ -37,7 +37,7 @@ class ListItem extends AbstractListItem {
->get('session') ->get('session')
->getSegment(SESSION_SEGMENT); ->getSegment(SESSION_SEGMENT);
if ($sessionSegment->get('auth_token') !== null) if ( ! is_null($sessionSegment->get('auth_token')))
{ {
$token = $sessionSegment->get('auth_token'); $token = $sessionSegment->get('auth_token');
return "bearer {$token}"; return "bearer {$token}";

View File

@ -68,7 +68,9 @@ class Model {
/** /**
* Constructor. * Constructor
*
* @param ListItem $listItem
*/ */
public function __construct(ListItem $listItem) public function __construct(ListItem $listItem)
{ {
@ -136,7 +138,7 @@ class Model {
return $data; return $data;
} }
return false; return FALSE;
} }
/** /**
@ -189,7 +191,7 @@ class Model {
} }
} }
return null; return NULL;
} }
/** /**
@ -233,6 +235,8 @@ class Model {
/** /**
* Get and transform the entirety of the user's anime list * Get and transform the entirety of the user's anime list
* *
* @param int $limit
* @param int $offset
* @return Request * @return Request
*/ */
public function getFullAnimeList(int $limit = 100, int $offset = 0): Request public function getFullAnimeList(int $limit = 100, int $offset = 0): Request

View File

@ -33,7 +33,6 @@ class AnimeListTransformer extends AbstractTransformer {
*/ */
public function transform($item) public function transform($item)
{ {
/* ?><pre><?= json_encode($item, \JSON_PRETTY_PRINT) ?></pre><?php */
$included = $item['included']; $included = $item['included'];
$animeId = $item['relationships']['media']['data']['id']; $animeId = $item['relationships']['media']['data']['id'];
$anime = $included['anime'][$animeId]; $anime = $included['anime'][$animeId];
@ -95,7 +94,7 @@ class AnimeListTransformer extends AbstractTransformer {
'rewatching' => (bool) $item['attributes']['reconsuming'], 'rewatching' => (bool) $item['attributes']['reconsuming'],
'rewatched' => (int) $item['attributes']['reconsumeCount'], 'rewatched' => (int) $item['attributes']['reconsumeCount'],
'user_rating' => ($rating === 0) ? '-' : (int) $rating, 'user_rating' => ($rating === 0) ? '-' : (int) $rating,
'private' => (bool) $item['attributes']['private'] ?? false, 'private' => (bool) $item['attributes']['private'] ?? FALSE,
]; ];
} }
@ -113,7 +112,7 @@ class AnimeListTransformer extends AbstractTransformer {
$untransformed = [ $untransformed = [
'id' => $item['id'], 'id' => $item['id'],
'mal_id' => $item['mal_id'] ?? null, 'mal_id' => $item['mal_id'] ?? NULL,
'data' => [ 'data' => [
'status' => $item['watching_status'], 'status' => $item['watching_status'],
'reconsuming' => $rewatching, 'reconsuming' => $rewatching,

View File

@ -35,7 +35,6 @@ class MangaListTransformer extends AbstractTransformer {
*/ */
public function transform($item) public function transform($item)
{ {
/*?><pre><?= print_r($item, TRUE) ?></pre><?php*/
$manga =& $item['manga']; $manga =& $item['manga'];
$rating = (is_numeric($item['attributes']['rating'])) $rating = (is_numeric($item['attributes']['rating']))

View File

@ -58,7 +58,7 @@ class MangaTransformer extends AbstractTransformer {
]; ];
} }
private function count(int $value = null) private function count(int $value = NULL)
{ {
return ((int)$value === 0) return ((int)$value === 0)
? '-' ? '-'