More refactoring, fix snapshot tests

This commit is contained in:
Timothy Warren 2018-08-08 13:05:38 -04:00
parent d29945eb96
commit 3b3156e78a
31 changed files with 549 additions and 319 deletions

View File

@ -26,7 +26,7 @@
<img src="<?= $urlGenerator->assetUrl('images/manga', "{$item['manga']['id']}.jpg") ?>" /> <img src="<?= $urlGenerator->assetUrl('images/manga', "{$item['manga']['id']}.jpg") ?>" />
<div class="name"> <div class="name">
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>"> <a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
<?= $escape->html(array_shift($item['manga']['titles'])) ?> <?= $escape->html($item['manga']['title']) ?>
<?php foreach($item['manga']['titles'] as $title): ?> <?php foreach($item['manga']['titles'] as $title): ?>
<br /><small><?= $title ?></small> <br /><small><?= $title ?></small>
<?php endforeach ?> <?php endforeach ?>

View File

@ -8,7 +8,7 @@
<thead> <thead>
<tr> <tr>
<th> <th>
<h3><?= $escape->html(array_shift($item['manga']['titles'])) ?></h3> <h3><?= $escape->html($item['manga']['title']) ?></h3>
<?php foreach($item['manga']['titles'] as $title): ?> <?php foreach($item['manga']['titles'] as $title): ?>
<h4><?= $escape->html($title) ?></h4> <h4><?= $escape->html($title) ?></h4>
<?php endforeach ?> <?php endforeach ?>
@ -44,12 +44,12 @@
<input type="number" min="0" name="chapters_read" id="chapters_read" value="<?= $item['chapters']['read'] ?>" /> / <?= $item['chapters']['total'] ?> <input type="number" min="0" name="chapters_read" id="chapters_read" value="<?= $item['chapters']['read'] ?>" /> / <?= $item['chapters']['total'] ?>
</td> </td>
</tr> </tr>
<? /*<tr> <tr>
<td><label for="volumes_read">Volumes Read</label></td> <td><label for="volumes_read">Volumes Read</label></td>
<td> <td>
<input type="number" min="0" name="volumes_read" id="volumes_read" value="<?= $item['volumes']['read'] ?>" /> / <?= $item['volumes']['total'] ?> <input type="text" disabled="disabled" min="0" name="volumes_read" id="volumes_read" value="-" /> / <?= $item['volumes']['total'] ?>
</td> </td>
</tr> */ ?> </tr>
<tr> <tr>
<td><label for="rereading_flag">Rereading?</label></td> <td><label for="rereading_flag">Rereading?</label></td>
<td> <td>

View File

@ -39,7 +39,7 @@
<?php endif ?> <?php endif ?>
<td class="align_left"> <td class="align_left">
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>"> <a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
<?= array_shift($item['manga']['titles']) ?> <?= $item['manga']['title'] ?>
</a> </a>
<?php foreach($item['manga']['titles'] as $title): ?> <?php foreach($item['manga']['titles'] as $title): ?>
<br /><?= $title ?> <br /><?= $title ?>

View File

@ -28,9 +28,12 @@ if ($timezone === '' || $timezone === FALSE)
// Load composer autoloader // Load composer autoloader
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
$whoops = new \Whoops\Run; // if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development')
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); {
$whoops->register(); $whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
}
// Define base directories // Define base directories
$APP_DIR = _dir(__DIR__, 'app'); $APP_DIR = _dir(__DIR__, 'app');

View File

@ -7,7 +7,7 @@ const atImport = require('postcss-import');
const cssNext = require('postcss-cssnext'); const cssNext = require('postcss-cssnext');
const cssNano = require('cssnano'); const cssNano = require('cssnano');
const css = fs.readFileSync('css/base.css', 'utf8'); const css = fs.readFileSync('css/base.css', 'utf-8');
postcss() postcss()
.use(atImport()) .use(atImport())

View File

@ -22,7 +22,7 @@ use Aviat\AnimeClient\API\HummingbirdClient;
use Aviat\Ion\{Json, JsonException}; use Aviat\Ion\{Json, JsonException};
// Include Amp and Artax // Include Amp and Artax
require_once('../vendor/autoload.php'); require_once '../vendor/autoload.php';
//Creative rewriting of /g/groupname to ?g=groupname //Creative rewriting of /g/groupname to ?g=groupname
$pi = $_SERVER['PATH_INFO']; $pi = $_SERVER['PATH_INFO'];
@ -318,10 +318,11 @@ class JSMin {
$lastModifiedDate = gmdate('D, d M Y H:i:s', $lastModified); $lastModifiedDate = gmdate('D, d M Y H:i:s', $lastModified);
$expiresDate = gmdate('D, d M Y H:i:s', $expires); $expiresDate = gmdate('D, d M Y H:i:s', $expires);
header("Content-Type: {$mimeType}; charset=utf8"); header("Content-Type: {$mimeType}; charset=utf-8");
header("Cache-control: public, max-age=691200, must-revalidate"); header('Cache-control: public, max-age=691200, must-revalidate');
header("Last-Modified: {$lastModifiedDate} GMT");
header("Expires: {$expiresDate} GMT"); header("Expires: {$expiresDate} GMT");
header("Last-Modified: {$lastModifiedDate} GMT");
header('X-Content-Type-Options: no-sniff');
echo $content; echo $content;
@ -335,7 +336,7 @@ class JSMin {
*/ */
public static function send304() public static function send304()
{ {
header("status: 304 Not Modified", true, 304); header('status: 304 Not Modified', true, 304);
} }
} }

0
public/js/cache/.gitkeep vendored Normal file → Executable file
View File

View File

@ -37,9 +37,11 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\{
MangaListTransformer MangaListTransformer
}; };
use Aviat\AnimeClient\Types\{ use Aviat\AnimeClient\Types\{
AbstractType,
Anime, Anime,
AnimeFormItem, FormItem,
AnimeListItem AnimeListItem,
MangaPage
}; };
use Aviat\Ion\{Di\ContainerAware, Json}; use Aviat\Ion\{Di\ContainerAware, Json};
@ -562,15 +564,15 @@ final class Model {
* Get information about a particular manga * Get information about a particular manga
* *
* @param string $slug * @param string $slug
* @return array * @return MangaPage
*/ */
public function getManga(string $slug): array public function getManga(string $slug): MangaPage
{ {
$baseData = $this->getRawMediaData('manga', $slug); $baseData = $this->getRawMediaData('manga', $slug);
if (empty($baseData)) if (empty($baseData))
{ {
return []; return new MangaPage([]);
} }
$transformed = $this->mangaTransformer->transform($baseData); $transformed = $this->mangaTransformer->transform($baseData);
@ -584,7 +586,7 @@ final class Model {
* @param string $mangaId * @param string $mangaId
* @return array * @return array
*/ */
public function getMangaById(string $mangaId): array public function getMangaById(string $mangaId): MangaPage
{ {
$baseData = $this->getRawMediaDataById('manga', $mangaId); $baseData = $this->getRawMediaDataById('manga', $mangaId);
return $this->mangaTransformer->transform($baseData); return $this->mangaTransformer->transform($baseData);
@ -837,10 +839,10 @@ final class Model {
/** /**
* Modify a list item * Modify a list item
* *
* @param AnimeFormItem $data * @param FormItem $data
* @return Request * @return Request
*/ */
public function updateListItem(AnimeFormItem $data): Request public function updateListItem(FormItem $data): Request
{ {
return $this->listItem->update($data['id'], $data['data']); return $this->listItem->update($data['id'], $data['data']);
} }

View File

@ -17,6 +17,10 @@
namespace Aviat\AnimeClient\API\Kitsu\Transformer; namespace Aviat\AnimeClient\API\Kitsu\Transformer;
use Aviat\AnimeClient\API\Kitsu; use Aviat\AnimeClient\API\Kitsu;
use Aviat\AnimeClient\Types\{
MangaFormItem, MangaFormItemData,
MangaListItem, MangaListItemDetail
};
use Aviat\Ion\StringWrapper; use Aviat\Ion\StringWrapper;
use Aviat\Ion\Transformer\AbstractTransformer; use Aviat\Ion\Transformer\AbstractTransformer;
@ -31,9 +35,9 @@ final class MangaListTransformer extends AbstractTransformer {
* Remap zipped anime data to a more logical form * Remap zipped anime data to a more logical form
* *
* @param array $item manga entry item * @param array $item manga entry item
* @return array * @return MangaListItem
*/ */
public function transform($item): array public function transform($item): MangaListItem
{ {
$included = $item['included']; $included = $item['included'];
$mangaId = $item['relationships']['media']['data']['id']; $mangaId = $item['relationships']['media']['data']['id'];
@ -72,7 +76,10 @@ final class MangaListTransformer extends AbstractTransformer {
} }
} }
$map = [ $titles = Kitsu::filterTitles($manga);
$title = array_shift($titles);
$map = new MangaListItem([
'id' => $item['id'], 'id' => $item['id'],
'mal_id' => $MALid, 'mal_id' => $MALid,
'chapters' => [ 'chapters' => [
@ -83,22 +90,22 @@ final class MangaListTransformer extends AbstractTransformer {
'read' => '-', //$item['attributes']['volumes_read'], 'read' => '-', //$item['attributes']['volumes_read'],
'total' => $totalVolumes 'total' => $totalVolumes
], ],
'manga' => [ 'manga' => new MangaListItemDetail([
'id' => $mangaId,
'titles' => Kitsu::filterTitles($manga),
'alternate_title' => NULL,
'slug' => $manga['slug'],
'url' => 'https://kitsu.io/manga/' . $manga['slug'],
'type' => $manga['mangaType'],
'image' => $manga['posterImage']['small'],
'genres' => $genres, 'genres' => $genres,
], 'id' => $mangaId,
'image' => $manga['posterImage']['small'],
'slug' => $manga['slug'],
'title' => $title,
'titles' => $titles,
'type' => $manga['mangaType'],
'url' => 'https://kitsu.io/manga/' . $manga['slug'],
]),
'reading_status' => $item['attributes']['status'], 'reading_status' => $item['attributes']['status'],
'notes' => $item['attributes']['notes'], 'notes' => $item['attributes']['notes'],
'rereading' => (bool)$item['attributes']['reconsuming'], 'rereading' => (bool)$item['attributes']['reconsuming'],
'reread' => $item['attributes']['reconsumeCount'], 'reread' => $item['attributes']['reconsumeCount'],
'user_rating' => $rating, 'user_rating' => $rating,
]; ]);
return $map; return $map;
} }
@ -107,22 +114,22 @@ final class MangaListTransformer extends AbstractTransformer {
* Untransform data to update the api * Untransform data to update the api
* *
* @param array $item * @param array $item
* @return array * @return MangaFormItem
*/ */
public function untransform($item): array public function untransform($item): MangaFormItem
{ {
$rereading = array_key_exists('rereading', $item) && (bool)$item['rereading']; $rereading = array_key_exists('rereading', $item) && (bool)$item['rereading'];
$map = [ $map = new MangaFormItem([
'id' => $item['id'], 'id' => $item['id'],
'mal_id' => $item['mal_id'], 'mal_id' => $item['mal_id'],
'data' => [ 'data' => new MangaFormItemData([
'status' => $item['status'], 'status' => $item['status'],
'reconsuming' => $rereading, 'reconsuming' => $rereading,
'reconsumeCount' => (int)$item['reread_count'], 'reconsumeCount' => (int)$item['reread_count'],
'notes' => $item['notes'], 'notes' => $item['notes'],
], ]),
]; ]);
if (is_numeric($item['chapters_read']) && $item['chapters_read'] > 0) if (is_numeric($item['chapters_read']) && $item['chapters_read'] > 0)
{ {

View File

@ -16,6 +16,7 @@
namespace Aviat\AnimeClient\API\Kitsu\Transformer; namespace Aviat\AnimeClient\API\Kitsu\Transformer;
use Aviat\AnimeClient\Types\MangaPage;
use Aviat\Ion\Transformer\AbstractTransformer; use Aviat\Ion\Transformer\AbstractTransformer;
/** /**
@ -28,23 +29,24 @@ final class MangaTransformer extends AbstractTransformer {
* logical and workable structure * logical and workable structure
* *
* @param array $item API library item * @param array $item API library item
* @return array * @return MangaPage
*/ */
public function transform($item) public function transform($item): MangaPage
{ {
// \dump($item);
$genres = []; $genres = [];
foreach($item['included'] as $included) foreach($item['included'] as $included)
{ {
if ($included['type'] === 'genres') if ($included['type'] === 'categories')
{ {
$genres[] = $included['attributes']['name']; $genres[] = $included['attributes']['title'];
} }
} }
sort($genres); sort($genres);
return [ return new MangaPage([
'id' => $item['id'], 'id' => $item['id'],
'title' => $item['canonicalTitle'], 'title' => $item['canonicalTitle'],
'en_title' => $item['titles']['en'], 'en_title' => $item['titles']['en'],
@ -56,7 +58,7 @@ final class MangaTransformer extends AbstractTransformer {
'synopsis' => $item['synopsis'], 'synopsis' => $item['synopsis'],
'url' => "https://kitsu.io/manga/{$item['slug']}", 'url' => "https://kitsu.io/manga/{$item['slug']}",
'genres' => $genres, 'genres' => $genres,
]; ]);
} }
private function count(int $value = NULL) private function count(int $value = NULL)

View File

@ -24,7 +24,7 @@ use Aviat\AnimeClient\API\MAL\{
}; };
use Aviat\AnimeClient\API\XML; use Aviat\AnimeClient\API\XML;
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus}; use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
use Aviat\AnimeClient\Types\{Anime, AnimeFormItem}; use Aviat\AnimeClient\Types\{Anime, FormItem};
use Aviat\Ion\Di\ContainerAware; use Aviat\Ion\Di\ContainerAware;
/** /**
@ -148,11 +148,11 @@ final class Model {
/** /**
* Update a list item * Update a list item
* *
* @param AnimeFormItem $data * @param FormItem $data
* @param string $type "anime" or "manga" * @param string $type "anime" or "manga"
* @return Request * @return Request
*/ */
public function updateListItem(AnimeFormItem $data, string $type = 'anime'): Request public function updateListItem(FormItem $data, string $type = 'anime'): Request
{ {
$updateData = []; $updateData = [];

View File

@ -29,7 +29,7 @@ use Aviat\Ion\Json;
/** /**
* Model for handling requests dealing with the anime list * Model for handling requests dealing with the anime list
*/ */
final class Anime extends API { class Anime extends API {
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* *

View File

@ -21,14 +21,18 @@ use Aviat\AnimeClient\API\{
Mapping\MangaReadingStatus, Mapping\MangaReadingStatus,
ParallelAPIRequest ParallelAPIRequest
}; };
use Aviat\AnimeClient\Types\{
MangaFormItem,
MangaListItem,
MangaPage
};
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Json; use Aviat\Ion\Json;
/** /**
* Model for handling requests dealing with the manga list * Model for handling requests dealing with the manga list
*/ */
final class Manga extends API class Manga extends API {
{
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* @var \Aviat\AnimeClient\API\Kitsu\Model * @var \Aviat\AnimeClient\API\Kitsu\Model
@ -71,17 +75,18 @@ final class Manga extends API
} }
$APIstatus = MangaReadingStatus::TITLE_TO_KITSU[$status]; $APIstatus = MangaReadingStatus::TITLE_TO_KITSU[$status];
$data = $this->kitsuModel->getMangaList($APIstatus); $data =
return $this->mapByStatus($data)[$status]; $this->mapByStatus($this->kitsuModel->getMangaList($APIstatus));
return $data[$status];
} }
/** /**
* Get the details of a manga * Get the details of a manga
* *
* @param string $manga_id * @param string $manga_id
* @return array * @return MangaPage
*/ */
public function getManga($manga_id): array public function getManga($manga_id): MangaPage
{ {
return $this->kitsuModel->getManga($manga_id); return $this->kitsuModel->getManga($manga_id);
} }
@ -90,9 +95,9 @@ final class Manga extends API
* Get anime by its kitsu id * Get anime by its kitsu id
* *
* @param string $animeId * @param string $animeId
* @return array * @return MangaPage
*/ */
public function getMangaById(string $animeId): array public function getMangaById(string $animeId): MangaPage
{ {
return $this->kitsuModel->getMangaById($animeId); return $this->kitsuModel->getMangaById($animeId);
} }
@ -102,9 +107,9 @@ final class Manga extends API
* for editing/updating that item * for editing/updating that item
* *
* @param string $itemId * @param string $itemId
* @return array * @return MangaListItem
*/ */
public function getLibraryItem(string $itemId): array public function getLibraryItem(string $itemId): MangaListItem
{ {
return $this->kitsuModel->getListItem($itemId); return $this->kitsuModel->getListItem($itemId);
} }
@ -141,10 +146,10 @@ final class Manga extends API
/** /**
* Update a list entry * Update a list entry
* *
* @param array $data * @param MangaFormItem $data
* @return array * @return array
*/ */
public function updateLibraryItem(array $data): array public function updateLibraryItem(MangaFormItem $data): array
{ {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
@ -221,7 +226,10 @@ final class Manga extends API
$output[$key][] = $entry; $output[$key][] = $entry;
} }
foreach ($output as &$val) { unset($entry);
foreach ($output as &$val)
{
$this->sortByName($val, 'manga'); $this->sortByName($val, 'manga');
} }

View File

@ -20,6 +20,17 @@ use ArrayAccess;
use LogicException; use LogicException;
abstract class AbstractType implements ArrayAccess { abstract class AbstractType implements ArrayAccess {
/**
* Populate values for unserializing data
*
* @param $properties
* @return mixed
*/
public static function __set_state($properties)
{
return new static($properties);
}
/** /**
* Sets the properties by using the constructor * Sets the properties by using the constructor
* *

View File

@ -19,8 +19,4 @@ namespace Aviat\AnimeClient\Types;
/** /**
* Type representing an Anime object for display * Type representing an Anime object for display
*/ */
final class AnimeFormItem extends AbstractType { final class AnimeFormItem extends FormItem { }
public $data;
public $id;
public $mal_id;
}

View File

@ -19,12 +19,4 @@ namespace Aviat\AnimeClient\Types;
/** /**
* Type representing an Anime object for display * Type representing an Anime object for display
*/ */
final class AnimeFormItemData extends AbstractType { final class AnimeFormItemData extends FormItemData {}
public $notes;
public $private;
public $progress;
public $rating;
public $reconsumeCount;
public $reconsuming;
public $status;
}

27
src/Types/FormItem.php Normal file
View File

@ -0,0 +1,27 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Types;
/**
* Type representing an Anime object for display
*/
abstract class FormItem extends AbstractType {
public $id;
public $mal_id;
public $data;
}

View File

@ -0,0 +1,30 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Types;
/**
* Type representing an Anime object for display
*/
abstract class FormItemData extends AbstractType {
public $notes;
public $private;
public $progress;
public $rating;
public $reconsumeCount;
public $reconsuming;
public $status;
}

View File

@ -0,0 +1,23 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Types;
/**
* Form data for updating a Manga List item
*/
final class MangaFormItem extends FormItem { }

View File

@ -0,0 +1,19 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Types;
final class MangaFormItemData extends FormItemData {}

View File

@ -0,0 +1,40 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Types;
/**
* Type representing an Anime object for display
*/
final class MangaListItem extends AbstractType {
public $id;
public $mal_id;
public $chapters = [
'read' => 0,
'total' => 0,
];
public $volumes = [
'read' => '-',
'total' => 0,
];
public $manga;
public $reading_status;
public $notes;
public $rereading;
public $reread;
public $user_rating;
}

View File

@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Types;
/**
* Type representing the manga represented by the list item
*/
final class MangaListItemDetail extends AbstractType {
public $genres;
public $id;
public $image;
public $slug;
public $title;
public $titles;
public $type;
public $url;
}

35
src/Types/MangaPage.php Normal file
View File

@ -0,0 +1,35 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Types;
/**
* Type representing an Anime object for display
*/
final class MangaPage extends AbstractType {
public $chapter_count;
public $cover_image;
public $en_title;
public $genres;
public $id;
public $included;
public $jp_title;
public $manga_type;
public $synopsis;
public $title;
public $url;
public $volume_count;
}

View File

@ -19,6 +19,10 @@ namespace Aviat\AnimeClient\Tests\API\Kitsu\Transformer;
use Aviat\AnimeClient\API\JsonAPI; use Aviat\AnimeClient\API\JsonAPI;
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
use Aviat\AnimeClient\Tests\AnimeClientTestCase; use Aviat\AnimeClient\Tests\AnimeClientTestCase;
use Aviat\AnimeClient\Types\{
MangaFormItem,
MangaFormItemData,
};
use Aviat\Ion\Json; use Aviat\Ion\Json;
class MangaListTransformerTest extends AnimeClientTestCase { class MangaListTransformerTest extends AnimeClientTestCase {
@ -82,18 +86,18 @@ class MangaListTransformerTest extends AnimeClientTestCase {
]; ];
$actual = $this->transformer->untransform($input); $actual = $this->transformer->untransform($input);
$expected = [ $expected = new MangaFormItem([
'id' => '15084773', 'id' => '15084773',
'mal_id' => '26769', 'mal_id' => '26769',
'data' => [ 'data' => new MangaFormItemData([
'status' => 'current', 'status' => 'current',
'progress' => 67, 'progress' => 67,
'reconsuming' => false, 'reconsuming' => false,
'reconsumeCount' => 0, 'reconsumeCount' => 0,
'notes' => '', 'notes' => '',
'rating' => 4.5 'rating' => 4.5
] ])
]; ]);
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }

View File

@ -1,46 +1,53 @@
<?php return array ( <?php return Aviat\AnimeClient\Types\AnimeListItem::__set_state(array(
'id' => '15839442', 'id' => '15839442',
'mal_id' => '33206', 'mal_id' => '33206',
'episodes' => 'episodes' =>
array ( array (
'watched' => '-', 'watched' => '-',
'total' => '-', 'total' => '-',
'length' => NULL, 'length' => NULL,
), ),
'airing' => 'airing' =>
array ( array (
'status' => 'Currently Airing', 'status' => 'Currently Airing',
'started' => '2017-01-12', 'started' => '2017-01-12',
'ended' => NULL, 'ended' => NULL,
), ),
'anime' => 'anime' =>
array ( Aviat\AnimeClient\Types\Anime::__set_state(array(
'id' => '12243', 'age_rating' => NULL,
'age_rating' => NULL, 'age_rating_guide' => NULL,
'title' => 'Kobayashi-san Chi no Maid Dragon', 'cover_image' => 'https://media.kitsu.io/anime/poster_images/12243/small.jpg?1481144116',
'titles' => 'episode_count' => NULL,
array ( 'episode_length' => NULL,
0 => 'Kobayashi-san Chi no Maid Dragon', 'genres' =>
1 => 'Miss Kobayashi\'s Dragon Maid',
2 => '小林さんちのメイドラゴン',
),
'slug' => 'kobayashi-san-chi-no-maid-dragon',
'type' => 'TV',
'image' => 'https://media.kitsu.io/anime/poster_images/12243/small.jpg?1481144116',
'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
1 => 'Fantasy', 1 => 'Fantasy',
2 => 'Slice of Life', 2 => 'Slice of Life',
), ),
'streaming_links' => 'id' => '12243',
'included' => NULL,
'show_type' => 'TV',
'slug' => 'kobayashi-san-chi-no-maid-dragon',
'status' => NULL,
'streaming_links' =>
array ( array (
), ),
), 'synopsis' => NULL,
'watching_status' => 'current', 'title' => 'Kobayashi-san Chi no Maid Dragon',
'notes' => NULL, 'titles' =>
'rewatching' => false, array (
'rewatched' => 0, 0 => 'Miss Kobayashi\'s Dragon Maid',
'user_rating' => '-', 1 => '小林さんちのメイドラゴン',
'private' => false, ),
); 'trailer_id' => NULL,
'url' => NULL,
)),
'watching_status' => 'current',
'notes' => NULL,
'rewatching' => false,
'rewatched' => 0,
'user_rating' => '-',
'private' => false,
));

View File

@ -1,14 +1,14 @@
<?php return array ( <?php return Aviat\AnimeClient\Types\AnimeFormItem::__set_state(array(
'id' => 14047981, 'id' => 14047981,
'mal_id' => NULL, 'mal_id' => NULL,
'data' => 'data' =>
array ( Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array(
'status' => 'current', 'notes' => 'Very formulaic.',
'reconsuming' => false, 'private' => false,
'reconsumeCount' => 0, 'progress' => 38,
'notes' => 'Very formulaic.', 'rating' => 4,
'progress' => 38, 'reconsumeCount' => 0,
'private' => false, 'reconsuming' => false,
'rating' => 4, 'status' => 'current',
), )),
); ));

View File

@ -1,14 +1,14 @@
<?php return array ( <?php return Aviat\AnimeClient\Types\AnimeFormItem::__set_state(array(
'id' => 14047981, 'id' => 14047981,
'mal_id' => '12345', 'mal_id' => '12345',
'data' => 'data' =>
array ( Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array(
'status' => 'current', 'notes' => 'Very formulaic.',
'reconsuming' => true, 'private' => true,
'reconsumeCount' => 0, 'progress' => 38,
'notes' => 'Very formulaic.', 'rating' => 4,
'progress' => 38, 'reconsumeCount' => 0,
'private' => true, 'reconsuming' => true,
'rating' => 4, 'status' => 'current',
), )),
); ));

View File

@ -1,13 +1,14 @@
<?php return array ( <?php return Aviat\AnimeClient\Types\AnimeFormItem::__set_state(array(
'id' => 14047983, 'id' => 14047983,
'mal_id' => '12347', 'mal_id' => '12347',
'data' => 'data' =>
array ( Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array(
'status' => 'current', 'notes' => '',
'reconsuming' => true, 'private' => true,
'reconsumeCount' => 0, 'progress' => 12,
'notes' => '', 'rating' => NULL,
'progress' => 12, 'reconsumeCount' => 0,
'private' => true, 'reconsuming' => true,
), 'status' => 'current',
); )),
));

View File

@ -1,17 +1,18 @@
<?php return array ( <?php return Aviat\AnimeClient\Types\Anime::__set_state(array(
'age_rating' => 'R', 'age_rating' => 'R',
'age_rating_guide' => 'Violence, Profanity', 'age_rating_guide' => 'Violence, Profanity',
'cover_image' => 'https://media.kitsu.io/anime/poster_images/7442/small.jpg?1418580054', 'cover_image' => 'https://media.kitsu.io/anime/poster_images/7442/small.jpg?1418580054',
'episode_count' => 25, 'episode_count' => 25,
'episode_length' => 24, 'episode_length' => 24,
'genres' => 'genres' =>
array ( array (
), ),
'id' => 32344, 'id' => 32344,
'show_type' => 'TV', 'included' => NULL,
'slug' => 'attack-on-titan', 'show_type' => 'TV',
'status' => 'Finished Airing', 'slug' => 'attack-on-titan',
'streaming_links' => 'status' => 'Finished Airing',
'streaming_links' =>
array ( array (
0 => 0 =>
array ( array (
@ -86,16 +87,15 @@
), ),
), ),
), ),
'synopsis' => 'Several hundred years ago, humans were nearly exterminated by titans. Titans are typically several stories tall, seem to have no intelligence, devour human beings and, worst of all, seem to do it for the pleasure rather than as a food source. A small percentage of humanity survived by enclosing themselves in a city protected by extremely high walls, even taller than the biggest of titans. Flash forward to the present and the city has not seen a titan in over 100 years. Teenage boy Eren and his foster sister Mikasa witness something horrific as the city walls are destroyed by a colossal titan that appears out of thin air. As the smaller titans flood the city, the two kids watch in horror as their mother is eaten alive. Eren vows that he will murder every single titan and take revenge for all of mankind. 'synopsis' => 'Several hundred years ago, humans were nearly exterminated by titans. Titans are typically several stories tall, seem to have no intelligence, devour human beings and, worst of all, seem to do it for the pleasure rather than as a food source. A small percentage of humanity survived by enclosing themselves in a city protected by extremely high walls, even taller than the biggest of titans. Flash forward to the present and the city has not seen a titan in over 100 years. Teenage boy Eren and his foster sister Mikasa witness something horrific as the city walls are destroyed by a colossal titan that appears out of thin air. As the smaller titans flood the city, the two kids watch in horror as their mother is eaten alive. Eren vows that he will murder every single titan and take revenge for all of mankind.
(Source: ANN)', (Source: ANN)',
'title' => 'Attack on Titan', 'title' => 'Attack on Titan',
'titles' => 'titles' =>
array ( array (
0 => 'Attack on Titan', 0 => 'Shingeki no Kyojin',
1 => 'Shingeki no Kyojin', 1 => '進撃の巨人',
2 => '進撃の巨人',
), ),
'trailer_id' => 'n4Nj6Y_SNYI', 'trailer_id' => 'n4Nj6Y_SNYI',
'url' => 'https://kitsu.io/anime/attack-on-titan', 'url' => 'https://kitsu.io/anime/attack-on-titan',
); ));

View File

@ -1,31 +1,21 @@
<?php return array ( <?php return array (
0 => 0 =>
array ( Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
'id' => '15084773', 'id' => '15084773',
'mal_id' => '26769', 'mal_id' => '26769',
'chapters' => 'chapters' =>
array ( array (
'read' => 67, 'read' => 67,
'total' => '-', 'total' => '-',
), ),
'volumes' => 'volumes' =>
array ( array (
'read' => '-', 'read' => '-',
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '20286', 'genres' =>
'titles' =>
array (
0 => 'Bokura wa Minna Kawaisou',
),
'alternate_title' => NULL,
'slug' => 'bokura-wa-minna-kawaisou',
'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou',
'type' => 'manga',
'image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
1 => 'Romance', 1 => 'Romance',
@ -33,40 +23,39 @@
3 => 'Slice of Life', 3 => 'Slice of Life',
4 => 'Thriller', 4 => 'Thriller',
), ),
), 'id' => '20286',
'reading_status' => 'current', 'image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'notes' => '', 'slug' => 'bokura-wa-minna-kawaisou',
'rereading' => false, 'title' => 'Bokura wa Minna Kawaisou',
'reread' => 0, 'titles' =>
'user_rating' => 9.0, array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou',
)),
'reading_status' => 'current',
'notes' => '',
'rereading' => false,
'reread' => 0,
'user_rating' => 9.0,
)),
1 => 1 =>
array ( Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
'id' => '15085607', 'id' => '15085607',
'mal_id' => '16', 'mal_id' => '16',
'chapters' => 'chapters' =>
array ( array (
'read' => 17, 'read' => 17,
'total' => 120, 'total' => 120,
), ),
'volumes' => 'volumes' =>
array ( array (
'read' => '-', 'read' => '-',
'total' => 14, 'total' => 14,
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '47', 'genres' =>
'titles' =>
array (
0 => 'Love Hina',
),
'alternate_title' => NULL,
'slug' => 'love-hina',
'url' => 'https://kitsu.io/manga/love-hina',
'type' => 'manga',
'image' => 'https://media.kitsu.io/manga/poster_images/47/small.jpg?1434249493',
'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
1 => 'Ecchi', 1 => 'Ecchi',
@ -74,41 +63,39 @@
3 => 'Romance', 3 => 'Romance',
4 => 'Sports', 4 => 'Sports',
), ),
), 'id' => '47',
'reading_status' => 'current', 'image' => 'https://media.kitsu.io/manga/poster_images/47/small.jpg?1434249493',
'notes' => '', 'slug' => 'love-hina',
'rereading' => false, 'title' => 'Love Hina',
'reread' => 0, 'titles' =>
'user_rating' => 7.0, array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/love-hina',
)),
'reading_status' => 'current',
'notes' => '',
'rereading' => false,
'reread' => 0,
'user_rating' => 7.0,
)),
2 => 2 =>
array ( Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
'id' => '15084529', 'id' => '15084529',
'mal_id' => '35003', 'mal_id' => '35003',
'chapters' => 'chapters' =>
array ( array (
'read' => 16, 'read' => 16,
'total' => '-', 'total' => '-',
), ),
'volumes' => 'volumes' =>
array ( array (
'read' => '-', 'read' => '-',
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '11777', 'genres' =>
'titles' =>
array (
0 => 'Yamada-kun to 7-nin no Majo',
1 => 'Yamada-kun and the Seven Witches',
),
'alternate_title' => NULL,
'slug' => 'yamada-kun-to-7-nin-no-majo',
'url' => 'https://kitsu.io/manga/yamada-kun-to-7-nin-no-majo',
'type' => 'manga',
'image' => 'https://media.kitsu.io/manga/poster_images/11777/small.jpg?1438784325',
'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
1 => 'Ecchi', 1 => 'Ecchi',
@ -118,89 +105,97 @@
5 => 'Sports', 5 => 'Sports',
6 => 'Supernatural', 6 => 'Supernatural',
), ),
), 'id' => '11777',
'reading_status' => 'current', 'image' => 'https://media.kitsu.io/manga/poster_images/11777/small.jpg?1438784325',
'notes' => '', 'slug' => 'yamada-kun-to-7-nin-no-majo',
'rereading' => false, 'title' => 'Yamada-kun to 7-nin no Majo',
'reread' => 0, 'titles' =>
'user_rating' => 9.0, array (
), 0 => 'Yamada-kun and the Seven Witches',
),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/yamada-kun-to-7-nin-no-majo',
)),
'reading_status' => 'current',
'notes' => '',
'rereading' => false,
'reread' => 0,
'user_rating' => 9.0,
)),
3 => 3 =>
array ( Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
'id' => '15312827', 'id' => '15312827',
'mal_id' => '78523', 'mal_id' => '78523',
'chapters' => 'chapters' =>
array ( array (
'read' => 68, 'read' => 68,
'total' => '-', 'total' => '-',
), ),
'volumes' => 'volumes' =>
array ( array (
'read' => '-', 'read' => '-',
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '27175', 'genres' =>
'titles' =>
array (
0 => 'ReLIFE',
),
'alternate_title' => NULL,
'slug' => 'relife',
'url' => 'https://kitsu.io/manga/relife',
'type' => 'manga',
'image' => 'https://media.kitsu.io/manga/poster_images/27175/small.jpg?1464379411',
'genres' =>
array ( array (
0 => 'Romance', 0 => 'Romance',
1 => 'School', 1 => 'School',
2 => 'Slice of Life', 2 => 'Slice of Life',
), ),
), 'id' => '27175',
'reading_status' => 'current', 'image' => 'https://media.kitsu.io/manga/poster_images/27175/small.jpg?1464379411',
'notes' => '', 'slug' => 'relife',
'rereading' => false, 'title' => 'ReLIFE',
'reread' => 0, 'titles' =>
'user_rating' => '-', array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/relife',
)),
'reading_status' => 'current',
'notes' => '',
'rereading' => false,
'reread' => 0,
'user_rating' => '-',
)),
4 => 4 =>
array ( Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
'id' => '15084769', 'id' => '15084769',
'mal_id' => '60815', 'mal_id' => '60815',
'chapters' => 'chapters' =>
array ( array (
'read' => 43, 'read' => 43,
'total' => '-', 'total' => '-',
), ),
'volumes' => 'volumes' =>
array ( array (
'read' => '-', 'read' => '-',
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '25491', 'genres' =>
'titles' =>
array (
0 => 'Joshikausei',
),
'alternate_title' => NULL,
'slug' => 'joshikausei',
'url' => 'https://kitsu.io/manga/joshikausei',
'type' => 'manga',
'image' => 'https://media.kitsu.io/manga/poster_images/25491/small.jpg?1434305043',
'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
1 => 'School', 1 => 'School',
2 => 'Slice of Life', 2 => 'Slice of Life',
), ),
), 'id' => '25491',
'reading_status' => 'current', 'image' => 'https://media.kitsu.io/manga/poster_images/25491/small.jpg?1434305043',
'notes' => '', 'slug' => 'joshikausei',
'rereading' => false, 'title' => 'Joshikausei',
'reread' => 0, 'titles' =>
'user_rating' => 8.0, array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/joshikausei',
)),
'reading_status' => 'current',
'notes' => '',
'rereading' => false,
'reread' => 0,
'user_rating' => 8.0,
)),
); );

View File

@ -1,21 +1,17 @@
<?php return array ( <?php return Aviat\AnimeClient\Types\MangaPage::__set_state(array(
'id' => '20286', 'chapter_count' => '-',
'title' => 'Bokura wa Minna Kawaisou', 'cover_image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'en_title' => NULL, 'en_title' => NULL,
'jp_title' => 'Bokura wa Minna Kawaisou', 'genres' =>
'cover_image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'manga_type' => 'manga',
'chapter_count' => '-',
'volume_count' => '-',
'synopsis' => 'Usa, a high-school student aspiring to begin a bachelor lifestyle, moves into a new apartment only to discover that he not only shares a room with a perverted roommate that has an obsession for underaged girls, but also that another girl, Ritsu, a love-at-first-sight, is living in the same building as well!
(Source: Kirei Cake)',
'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou',
'genres' =>
array ( array (
0 => 'Comedy',
1 => 'Romance',
2 => 'School',
3 => 'Slice of Life',
4 => 'Thriller',
), ),
); 'id' => '20286',
'included' => NULL,
'jp_title' => 'Bokura wa Minna Kawaisou',
'manga_type' => 'manga',
'synopsis' => 'Usa, a high-school student aspiring to begin a bachelor lifestyle, moves into a new apartment only to discover that he not only shares a room with a perverted roommate that has an obsession for underaged girls, but also that another girl, Ritsu, a love-at-first-sight, is living in the same building as well!
(Source: Kirei Cake)',
'title' => 'Bokura wa Minna Kawaisou',
'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou',
'volume_count' => '-',
));