More refactoring, fix snapshot tests

This commit is contained in:
Timothy Warren 2018-08-08 13:05:38 -04:00
parent 06c55a2094
commit be2b387391
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,4 +1,4 @@
<?php return array ( <?php return Aviat\AnimeClient\Types\AnimeListItem::__set_state(array(
'id' => '15839442', 'id' => '15839442',
'mal_id' => '33206', 'mal_id' => '33206',
'episodes' => 'episodes' =>
@ -14,33 +14,40 @@
'ended' => NULL, 'ended' => NULL,
), ),
'anime' => 'anime' =>
array ( Aviat\AnimeClient\Types\Anime::__set_state(array(
'id' => '12243',
'age_rating' => NULL, 'age_rating' => NULL,
'title' => 'Kobayashi-san Chi no Maid Dragon', 'age_rating_guide' => NULL,
'titles' => 'cover_image' => 'https://media.kitsu.io/anime/poster_images/12243/small.jpg?1481144116',
array ( 'episode_count' => NULL,
0 => 'Kobayashi-san Chi no Maid Dragon', 'episode_length' => NULL,
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' => 'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
1 => 'Fantasy', 1 => 'Fantasy',
2 => 'Slice of Life', 2 => 'Slice of Life',
), ),
'id' => '12243',
'included' => NULL,
'show_type' => 'TV',
'slug' => 'kobayashi-san-chi-no-maid-dragon',
'status' => NULL,
'streaming_links' => 'streaming_links' =>
array ( array (
), ),
'synopsis' => NULL,
'title' => 'Kobayashi-san Chi no Maid Dragon',
'titles' =>
array (
0 => 'Miss Kobayashi\'s Dragon Maid',
1 => '小林さんちのメイドラゴン',
), ),
'trailer_id' => NULL,
'url' => NULL,
)),
'watching_status' => 'current', 'watching_status' => 'current',
'notes' => NULL, 'notes' => NULL,
'rewatching' => false, 'rewatching' => false,
'rewatched' => 0, 'rewatched' => 0,
'user_rating' => '-', 'user_rating' => '-',
'private' => false, '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',
'reconsuming' => false,
'reconsumeCount' => 0,
'notes' => 'Very formulaic.', 'notes' => 'Very formulaic.',
'progress' => 38,
'private' => false, 'private' => false,
'progress' => 38,
'rating' => 4, 'rating' => 4,
), 'reconsumeCount' => 0,
); 'reconsuming' => false,
'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',
'reconsuming' => true,
'reconsumeCount' => 0,
'notes' => 'Very formulaic.', 'notes' => 'Very formulaic.',
'progress' => 38,
'private' => true, 'private' => true,
'progress' => 38,
'rating' => 4, 'rating' => 4,
), 'reconsumeCount' => 0,
); 'reconsuming' => true,
'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',
'reconsuming' => true,
'reconsumeCount' => 0,
'notes' => '', 'notes' => '',
'progress' => 12,
'private' => true, 'private' => true,
), 'progress' => 12,
); 'rating' => NULL,
'reconsumeCount' => 0,
'reconsuming' => true,
'status' => 'current',
)),
));

View File

@ -1,4 +1,4 @@
<?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',
@ -8,6 +8,7 @@
array ( array (
), ),
'id' => 32344, 'id' => 32344,
'included' => NULL,
'show_type' => 'TV', 'show_type' => 'TV',
'slug' => 'attack-on-titan', 'slug' => 'attack-on-titan',
'status' => 'Finished Airing', 'status' => 'Finished Airing',
@ -92,10 +93,9 @@
'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,6 +1,6 @@
<?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' =>
@ -14,17 +14,7 @@
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '20286',
'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' => 'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
@ -33,15 +23,24 @@
3 => 'Slice of Life', 3 => 'Slice of Life',
4 => 'Thriller', 4 => 'Thriller',
), ),
'id' => '20286',
'image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'slug' => 'bokura-wa-minna-kawaisou',
'title' => 'Bokura wa Minna Kawaisou',
'titles' =>
array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou',
)),
'reading_status' => 'current', 'reading_status' => 'current',
'notes' => '', 'notes' => '',
'rereading' => false, 'rereading' => false,
'reread' => 0, 'reread' => 0,
'user_rating' => 9.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' =>
@ -55,17 +54,7 @@
'total' => 14, 'total' => 14,
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '47',
'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' => 'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
@ -74,15 +63,24 @@
3 => 'Romance', 3 => 'Romance',
4 => 'Sports', 4 => 'Sports',
), ),
'id' => '47',
'image' => 'https://media.kitsu.io/manga/poster_images/47/small.jpg?1434249493',
'slug' => 'love-hina',
'title' => 'Love Hina',
'titles' =>
array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/love-hina',
)),
'reading_status' => 'current', 'reading_status' => 'current',
'notes' => '', 'notes' => '',
'rereading' => false, 'rereading' => false,
'reread' => 0, 'reread' => 0,
'user_rating' => 7.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' =>
@ -96,18 +94,7 @@
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '11777',
'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' => 'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
@ -118,15 +105,25 @@
5 => 'Sports', 5 => 'Sports',
6 => 'Supernatural', 6 => 'Supernatural',
), ),
'id' => '11777',
'image' => 'https://media.kitsu.io/manga/poster_images/11777/small.jpg?1438784325',
'slug' => 'yamada-kun-to-7-nin-no-majo',
'title' => 'Yamada-kun to 7-nin no Majo',
'titles' =>
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', 'reading_status' => 'current',
'notes' => '', 'notes' => '',
'rereading' => false, 'rereading' => false,
'reread' => 0, 'reread' => 0,
'user_rating' => 9.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' =>
@ -140,32 +137,31 @@
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '27175',
'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' => 'genres' =>
array ( array (
0 => 'Romance', 0 => 'Romance',
1 => 'School', 1 => 'School',
2 => 'Slice of Life', 2 => 'Slice of Life',
), ),
'id' => '27175',
'image' => 'https://media.kitsu.io/manga/poster_images/27175/small.jpg?1464379411',
'slug' => 'relife',
'title' => 'ReLIFE',
'titles' =>
array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/relife',
)),
'reading_status' => 'current', 'reading_status' => 'current',
'notes' => '', 'notes' => '',
'rereading' => false, 'rereading' => false,
'reread' => 0, 'reread' => 0,
'user_rating' => '-', 'user_rating' => '-',
), )),
4 => 4 =>
array ( Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
'id' => '15084769', 'id' => '15084769',
'mal_id' => '60815', 'mal_id' => '60815',
'chapters' => 'chapters' =>
@ -179,28 +175,27 @@
'total' => '-', 'total' => '-',
), ),
'manga' => 'manga' =>
array ( Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
'id' => '25491',
'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' => 'genres' =>
array ( array (
0 => 'Comedy', 0 => 'Comedy',
1 => 'School', 1 => 'School',
2 => 'Slice of Life', 2 => 'Slice of Life',
), ),
'id' => '25491',
'image' => 'https://media.kitsu.io/manga/poster_images/25491/small.jpg?1434305043',
'slug' => 'joshikausei',
'title' => 'Joshikausei',
'titles' =>
array (
), ),
'type' => 'manga',
'url' => 'https://kitsu.io/manga/joshikausei',
)),
'reading_status' => 'current', 'reading_status' => 'current',
'notes' => '', 'notes' => '',
'rereading' => false, 'rereading' => false,
'reread' => 0, 'reread' => 0,
'user_rating' => 8.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',
'title' => 'Bokura wa Minna Kawaisou',
'en_title' => NULL,
'jp_title' => 'Bokura wa Minna Kawaisou',
'cover_image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'manga_type' => 'manga',
'chapter_count' => '-', 'chapter_count' => '-',
'volume_count' => '-', 'cover_image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'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! 'en_title' => NULL,
(Source: Kirei Cake)',
'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou',
'genres' => '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' => '-',
));