More code style fixes

This commit is contained in:
Timothy Warren 2017-02-17 11:37:22 -05:00
parent 30b43fd27c
commit 93038e61e5
6 changed files with 19 additions and 25 deletions

View File

@ -65,7 +65,7 @@ trait KitsuTrait {
->get('session')
->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');
$request = $request->setAuth('bearer', $token);
@ -104,14 +104,6 @@ trait KitsuTrait {
$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;
}
@ -125,7 +117,7 @@ trait KitsuTrait {
*/
private function request(string $type, string $url, array $options = []): array
{
$logger = null;
$logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('kitsu-request');
@ -133,7 +125,7 @@ trait KitsuTrait {
$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)
{
@ -147,7 +139,7 @@ trait KitsuTrait {
/**
* Remove some boilerplate for get requests
*
* @param array $args
* @param mixed ...$args
* @return array
*/
protected function getRequest(...$args): array
@ -158,7 +150,7 @@ trait KitsuTrait {
/**
* Remove some boilerplate for patch requests
*
* @param array $args
* @param mixed ...$args
* @return array
*/
protected function patchRequest(...$args): array
@ -169,12 +161,12 @@ trait KitsuTrait {
/**
* Remove some boilerplate for post requests
*
* @param array $args
* @param mixed ...$args
* @return array
*/
protected function postRequest(...$args): array
{
$logger = null;
$logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('kitsu-request');
@ -197,7 +189,7 @@ trait KitsuTrait {
/**
* Remove some boilerplate for delete requests
*
* @param array $args
* @param mixed ...$args
* @return bool
*/
protected function deleteRequest(...$args): bool

View File

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

View File

@ -68,7 +68,9 @@ class Model {
/**
* Constructor.
* Constructor
*
* @param ListItem $listItem
*/
public function __construct(ListItem $listItem)
{
@ -136,7 +138,7 @@ class Model {
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
*
* @param int $limit
* @param int $offset
* @return 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)
{
/* ?><pre><?= json_encode($item, \JSON_PRETTY_PRINT) ?></pre><?php */
$included = $item['included'];
$animeId = $item['relationships']['media']['data']['id'];
$anime = $included['anime'][$animeId];
@ -95,7 +94,7 @@ class AnimeListTransformer extends AbstractTransformer {
'rewatching' => (bool) $item['attributes']['reconsuming'],
'rewatched' => (int) $item['attributes']['reconsumeCount'],
'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 = [
'id' => $item['id'],
'mal_id' => $item['mal_id'] ?? null,
'mal_id' => $item['mal_id'] ?? NULL,
'data' => [
'status' => $item['watching_status'],
'reconsuming' => $rewatching,

View File

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