Miscellaneous code cleanup

This commit is contained in:
Timothy Warren 2017-03-20 19:08:33 -04:00
parent cd242596bc
commit 1a45e57b7c
7 changed files with 6 additions and 23 deletions

View File

@ -84,7 +84,7 @@
<h2>Characters</h2> <h2>Characters</h2>
<div class="flex flex-wrap"> <div class="flex flex-wrap">
<?php foreach($characters as $char): ?> <?php foreach($characters as $char): ?>
<?php if (array_key_exists('image', $char)): ?> <?php if ( ! empty($char['image']['original'])): ?>
<div class="character"> <div class="character">
<?php $link = $url->generate('character', ['slug' => $char['slug']]) ?> <?php $link = $url->generate('character', ['slug' => $char['slug']]) ?>
<?= $helper->a($link, $char['name']); ?> <?= $helper->a($link, $char['name']); ?>

View File

@ -35,9 +35,9 @@
<dt>About:</dt> <dt>About:</dt>
<dd><?= $escape->html($attributes['bio']) ?></dd> <dd><?= $escape->html($attributes['bio']) ?></dd>
</dl> </dl>
<pre><?= json_encode($attributes, \JSON_PRETTY_PRINT) ?></pre> <?php /* <pre><?= json_encode($attributes, \JSON_PRETTY_PRINT) ?></pre>
<pre><?= json_encode($relationships, \JSON_PRETTY_PRINT) ?></pre> <pre><?= json_encode($relationships, \JSON_PRETTY_PRINT) ?></pre>
<pre><?= json_encode($included, \JSON_PRETTY_PRINT) ?></pre> <pre><?= json_encode($included, \JSON_PRETTY_PRINT) ?></pre> */ ?>
</div> </div>
</section> </section>
</main> </main>

View File

@ -17,12 +17,7 @@
namespace Aviat\AnimeClient\API; namespace Aviat\AnimeClient\API;
use Amp; use Amp;
use Amp\Artax\{ use Amp\Artax\{FormBody, Request};
Client,
FormBody,
Request
};
use Aviat\Ion\Di\ContainerAware;
use Aviat\Ion\Json; use Aviat\Ion\Json;
use InvalidArgumentException; use InvalidArgumentException;
use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerAwareTrait;

View File

@ -16,8 +16,6 @@
namespace Aviat\AnimeClient\API; namespace Aviat\AnimeClient\API;
use Aviat\Ion\Json;
/** /**
* Class encapsulating Json API data structure for a request or response * Class encapsulating Json API data structure for a request or response
*/ */

View File

@ -19,10 +19,6 @@ namespace Aviat\AnimeClient\API;
use Aviat\AnimeClient\API\Kitsu\Enum\AnimeAiringStatus; use Aviat\AnimeClient\API\Kitsu\Enum\AnimeAiringStatus;
use DateTimeImmutable; use DateTimeImmutable;
const AUTH_URL = 'https://kitsu.io/api/oauth/token';
const AUTH_USER_ID_KEY = 'kitsu-auth-userid';
const AUTH_TOKEN_CACHE_KEY = 'kitsu-auth-token';
/** /**
* Data massaging helpers for the Kitsu API * Data massaging helpers for the Kitsu API
*/ */

View File

@ -20,7 +20,6 @@ use Aviat\AnimeClient\API\{
APIRequestBuilder, APIRequestBuilder,
Kitsu as K Kitsu as K
}; };
use Aviat\Ion\Json;
class KitsuRequestBuilder extends APIRequestBuilder { class KitsuRequestBuilder extends APIRequestBuilder {

View File

@ -24,14 +24,12 @@ use Amp\Artax\{Client, Request};
use Aviat\AnimeClient\AnimeClient; use Aviat\AnimeClient\AnimeClient;
use Aviat\AnimeClient\API\Kitsu as K; use Aviat\AnimeClient\API\Kitsu as K;
use Aviat\Ion\Json; use Aviat\Ion\Json;
use InvalidArgumentException;
use RuntimeException;
trait KitsuTrait { trait KitsuTrait {
/** /**
* The request builder for the MAL API * The request builder for the MAL API
* @var MALRequestBuilder * @var KitsuRequestBuilder
*/ */
protected $requestBuilder; protected $requestBuilder;
@ -57,8 +55,6 @@ trait KitsuTrait {
*/ */
public function setUpRequest(string $type, string $url, array $options = []): Request public function setUpRequest(string $type, string $url, array $options = []): Request
{ {
$config = $this->container->get('config');
$request = $this->requestBuilder->newRequest($type, $url); $request = $this->requestBuilder->newRequest($type, $url);
$sessionSegment = $this->getContainer() $sessionSegment = $this->getContainer()
@ -100,7 +96,6 @@ trait KitsuTrait {
private function getResponse(string $type, string $url, array $options = []) private function getResponse(string $type, string $url, array $options = [])
{ {
$request = $this->setUpRequest($type, $url, $options); $request = $this->setUpRequest($type, $url, $options);
$logger = $this->container->getLogger('kitsu-request');
$response = wait((new Client)->request($request)); $response = wait((new Client)->request($request));
@ -133,7 +128,7 @@ trait KitsuTrait {
} }
} }
return JSON::decode($response->getBody(), TRUE); return Json::decode($response->getBody(), TRUE);
} }
/** /**