Version 5.1 - All the GraphQL #32
@ -26,7 +26,7 @@
|
||||
<img src="<?= $urlGenerator->assetUrl('images/manga', "{$item['manga']['id']}.jpg") ?>" />
|
||||
<div class="name">
|
||||
<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): ?>
|
||||
<br /><small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<h3><?= $escape->html(array_shift($item['manga']['titles'])) ?></h3>
|
||||
<h3><?= $escape->html($item['manga']['title']) ?></h3>
|
||||
<?php foreach($item['manga']['titles'] as $title): ?>
|
||||
<h4><?= $escape->html($title) ?></h4>
|
||||
<?php endforeach ?>
|
||||
@ -44,12 +44,12 @@
|
||||
<input type="number" min="0" name="chapters_read" id="chapters_read" value="<?= $item['chapters']['read'] ?>" /> / <?= $item['chapters']['total'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<? /*<tr>
|
||||
<tr>
|
||||
<td><label for="volumes_read">Volumes Read</label></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>
|
||||
</tr> */ ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="rereading_flag">Rereading?</label></td>
|
||||
<td>
|
||||
|
@ -39,7 +39,7 @@
|
||||
<?php endif ?>
|
||||
<td class="align_left">
|
||||
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
|
||||
<?= array_shift($item['manga']['titles']) ?>
|
||||
<?= $item['manga']['title'] ?>
|
||||
</a>
|
||||
<?php foreach($item['manga']['titles'] as $title): ?>
|
||||
<br /><?= $title ?>
|
||||
|
@ -28,9 +28,12 @@ if ($timezone === '' || $timezone === FALSE)
|
||||
// Load composer autoloader
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$whoops = new \Whoops\Run;
|
||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
$whoops->register();
|
||||
// if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development')
|
||||
{
|
||||
$whoops = new \Whoops\Run;
|
||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
$whoops->register();
|
||||
}
|
||||
|
||||
// Define base directories
|
||||
$APP_DIR = _dir(__DIR__, 'app');
|
||||
|
@ -7,7 +7,7 @@ const atImport = require('postcss-import');
|
||||
const cssNext = require('postcss-cssnext');
|
||||
const cssNano = require('cssnano');
|
||||
|
||||
const css = fs.readFileSync('css/base.css', 'utf8');
|
||||
const css = fs.readFileSync('css/base.css', 'utf-8');
|
||||
|
||||
postcss()
|
||||
.use(atImport())
|
||||
|
@ -22,7 +22,7 @@ use Aviat\AnimeClient\API\HummingbirdClient;
|
||||
use Aviat\Ion\{Json, JsonException};
|
||||
|
||||
// Include Amp and Artax
|
||||
require_once('../vendor/autoload.php');
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
//Creative rewriting of /g/groupname to ?g=groupname
|
||||
$pi = $_SERVER['PATH_INFO'];
|
||||
@ -318,10 +318,11 @@ class JSMin {
|
||||
$lastModifiedDate = gmdate('D, d M Y H:i:s', $lastModified);
|
||||
$expiresDate = gmdate('D, d M Y H:i:s', $expires);
|
||||
|
||||
header("Content-Type: {$mimeType}; charset=utf8");
|
||||
header("Cache-control: public, max-age=691200, must-revalidate");
|
||||
header("Last-Modified: {$lastModifiedDate} GMT");
|
||||
header("Content-Type: {$mimeType}; charset=utf-8");
|
||||
header('Cache-control: public, max-age=691200, must-revalidate');
|
||||
header("Expires: {$expiresDate} GMT");
|
||||
header("Last-Modified: {$lastModifiedDate} GMT");
|
||||
header('X-Content-Type-Options: no-sniff');
|
||||
|
||||
echo $content;
|
||||
|
||||
@ -335,7 +336,7 @@ class JSMin {
|
||||
*/
|
||||
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
0
public/js/cache/.gitkeep
vendored
Normal file → Executable file
@ -37,9 +37,11 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\{
|
||||
MangaListTransformer
|
||||
};
|
||||
use Aviat\AnimeClient\Types\{
|
||||
AbstractType,
|
||||
Anime,
|
||||
AnimeFormItem,
|
||||
AnimeListItem
|
||||
FormItem,
|
||||
AnimeListItem,
|
||||
MangaPage
|
||||
};
|
||||
use Aviat\Ion\{Di\ContainerAware, Json};
|
||||
|
||||
@ -562,15 +564,15 @@ final class Model {
|
||||
* Get information about a particular manga
|
||||
*
|
||||
* @param string $slug
|
||||
* @return array
|
||||
* @return MangaPage
|
||||
*/
|
||||
public function getManga(string $slug): array
|
||||
public function getManga(string $slug): MangaPage
|
||||
{
|
||||
$baseData = $this->getRawMediaData('manga', $slug);
|
||||
|
||||
if (empty($baseData))
|
||||
{
|
||||
return [];
|
||||
return new MangaPage([]);
|
||||
}
|
||||
|
||||
$transformed = $this->mangaTransformer->transform($baseData);
|
||||
@ -584,7 +586,7 @@ final class Model {
|
||||
* @param string $mangaId
|
||||
* @return array
|
||||
*/
|
||||
public function getMangaById(string $mangaId): array
|
||||
public function getMangaById(string $mangaId): MangaPage
|
||||
{
|
||||
$baseData = $this->getRawMediaDataById('manga', $mangaId);
|
||||
return $this->mangaTransformer->transform($baseData);
|
||||
@ -837,10 +839,10 @@ final class Model {
|
||||
/**
|
||||
* Modify a list item
|
||||
*
|
||||
* @param AnimeFormItem $data
|
||||
* @param FormItem $data
|
||||
* @return Request
|
||||
*/
|
||||
public function updateListItem(AnimeFormItem $data): Request
|
||||
public function updateListItem(FormItem $data): Request
|
||||
{
|
||||
return $this->listItem->update($data['id'], $data['data']);
|
||||
}
|
||||
|
@ -17,6 +17,10 @@
|
||||
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
|
||||
|
||||
use Aviat\AnimeClient\API\Kitsu;
|
||||
use Aviat\AnimeClient\Types\{
|
||||
MangaFormItem, MangaFormItemData,
|
||||
MangaListItem, MangaListItemDetail
|
||||
};
|
||||
use Aviat\Ion\StringWrapper;
|
||||
use Aviat\Ion\Transformer\AbstractTransformer;
|
||||
|
||||
@ -31,9 +35,9 @@ final class MangaListTransformer extends AbstractTransformer {
|
||||
* Remap zipped anime data to a more logical form
|
||||
*
|
||||
* @param array $item manga entry item
|
||||
* @return array
|
||||
* @return MangaListItem
|
||||
*/
|
||||
public function transform($item): array
|
||||
public function transform($item): MangaListItem
|
||||
{
|
||||
$included = $item['included'];
|
||||
$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'],
|
||||
'mal_id' => $MALid,
|
||||
'chapters' => [
|
||||
@ -83,22 +90,22 @@ final class MangaListTransformer extends AbstractTransformer {
|
||||
'read' => '-', //$item['attributes']['volumes_read'],
|
||||
'total' => $totalVolumes
|
||||
],
|
||||
'manga' => [
|
||||
'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'],
|
||||
'manga' => new MangaListItemDetail([
|
||||
'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'],
|
||||
'notes' => $item['attributes']['notes'],
|
||||
'rereading' => (bool)$item['attributes']['reconsuming'],
|
||||
'reread' => $item['attributes']['reconsumeCount'],
|
||||
'user_rating' => $rating,
|
||||
];
|
||||
]);
|
||||
|
||||
return $map;
|
||||
}
|
||||
@ -107,22 +114,22 @@ final class MangaListTransformer extends AbstractTransformer {
|
||||
* Untransform data to update the api
|
||||
*
|
||||
* @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'];
|
||||
|
||||
$map = [
|
||||
$map = new MangaFormItem([
|
||||
'id' => $item['id'],
|
||||
'mal_id' => $item['mal_id'],
|
||||
'data' => [
|
||||
'data' => new MangaFormItemData([
|
||||
'status' => $item['status'],
|
||||
'reconsuming' => $rereading,
|
||||
'reconsumeCount' => (int)$item['reread_count'],
|
||||
'notes' => $item['notes'],
|
||||
],
|
||||
];
|
||||
]),
|
||||
]);
|
||||
|
||||
if (is_numeric($item['chapters_read']) && $item['chapters_read'] > 0)
|
||||
{
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
|
||||
|
||||
use Aviat\AnimeClient\Types\MangaPage;
|
||||
use Aviat\Ion\Transformer\AbstractTransformer;
|
||||
|
||||
/**
|
||||
@ -28,23 +29,24 @@ final class MangaTransformer extends AbstractTransformer {
|
||||
* logical and workable structure
|
||||
*
|
||||
* @param array $item API library item
|
||||
* @return array
|
||||
* @return MangaPage
|
||||
*/
|
||||
public function transform($item)
|
||||
public function transform($item): MangaPage
|
||||
{
|
||||
// \dump($item);
|
||||
$genres = [];
|
||||
|
||||
foreach($item['included'] as $included)
|
||||
{
|
||||
if ($included['type'] === 'genres')
|
||||
if ($included['type'] === 'categories')
|
||||
{
|
||||
$genres[] = $included['attributes']['name'];
|
||||
$genres[] = $included['attributes']['title'];
|
||||
}
|
||||
}
|
||||
|
||||
sort($genres);
|
||||
|
||||
return [
|
||||
return new MangaPage([
|
||||
'id' => $item['id'],
|
||||
'title' => $item['canonicalTitle'],
|
||||
'en_title' => $item['titles']['en'],
|
||||
@ -56,7 +58,7 @@ final class MangaTransformer extends AbstractTransformer {
|
||||
'synopsis' => $item['synopsis'],
|
||||
'url' => "https://kitsu.io/manga/{$item['slug']}",
|
||||
'genres' => $genres,
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
private function count(int $value = NULL)
|
||||
|
@ -24,7 +24,7 @@ use Aviat\AnimeClient\API\MAL\{
|
||||
};
|
||||
use Aviat\AnimeClient\API\XML;
|
||||
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
|
||||
use Aviat\AnimeClient\Types\{Anime, AnimeFormItem};
|
||||
use Aviat\AnimeClient\Types\{Anime, FormItem};
|
||||
use Aviat\Ion\Di\ContainerAware;
|
||||
|
||||
/**
|
||||
@ -148,11 +148,11 @@ final class Model {
|
||||
/**
|
||||
* Update a list item
|
||||
*
|
||||
* @param AnimeFormItem $data
|
||||
* @param FormItem $data
|
||||
* @param string $type "anime" or "manga"
|
||||
* @return Request
|
||||
*/
|
||||
public function updateListItem(AnimeFormItem $data, string $type = 'anime'): Request
|
||||
public function updateListItem(FormItem $data, string $type = 'anime'): Request
|
||||
{
|
||||
$updateData = [];
|
||||
|
||||
|
@ -29,7 +29,7 @@ use Aviat\Ion\Json;
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@ -21,14 +21,18 @@ use Aviat\AnimeClient\API\{
|
||||
Mapping\MangaReadingStatus,
|
||||
ParallelAPIRequest
|
||||
};
|
||||
use Aviat\AnimeClient\Types\{
|
||||
MangaFormItem,
|
||||
MangaListItem,
|
||||
MangaPage
|
||||
};
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @var \Aviat\AnimeClient\API\Kitsu\Model
|
||||
@ -71,17 +75,18 @@ final class Manga extends API
|
||||
}
|
||||
|
||||
$APIstatus = MangaReadingStatus::TITLE_TO_KITSU[$status];
|
||||
$data = $this->kitsuModel->getMangaList($APIstatus);
|
||||
return $this->mapByStatus($data)[$status];
|
||||
$data =
|
||||
$this->mapByStatus($this->kitsuModel->getMangaList($APIstatus));
|
||||
return $data[$status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the details of a manga
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
@ -90,9 +95,9 @@ final class Manga extends API
|
||||
* Get anime by its kitsu id
|
||||
*
|
||||
* @param string $animeId
|
||||
* @return array
|
||||
* @return MangaPage
|
||||
*/
|
||||
public function getMangaById(string $animeId): array
|
||||
public function getMangaById(string $animeId): MangaPage
|
||||
{
|
||||
return $this->kitsuModel->getMangaById($animeId);
|
||||
}
|
||||
@ -102,9 +107,9 @@ final class Manga extends API
|
||||
* for editing/updating that item
|
||||
*
|
||||
* @param string $itemId
|
||||
* @return array
|
||||
* @return MangaListItem
|
||||
*/
|
||||
public function getLibraryItem(string $itemId): array
|
||||
public function getLibraryItem(string $itemId): MangaListItem
|
||||
{
|
||||
return $this->kitsuModel->getListItem($itemId);
|
||||
}
|
||||
@ -141,10 +146,10 @@ final class Manga extends API
|
||||
/**
|
||||
* Update a list entry
|
||||
*
|
||||
* @param array $data
|
||||
* @param MangaFormItem $data
|
||||
* @return array
|
||||
*/
|
||||
public function updateLibraryItem(array $data): array
|
||||
public function updateLibraryItem(MangaFormItem $data): array
|
||||
{
|
||||
$requester = new ParallelAPIRequest();
|
||||
|
||||
@ -221,7 +226,10 @@ final class Manga extends API
|
||||
$output[$key][] = $entry;
|
||||
}
|
||||
|
||||
foreach ($output as &$val) {
|
||||
unset($entry);
|
||||
|
||||
foreach ($output as &$val)
|
||||
{
|
||||
$this->sortByName($val, 'manga');
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,17 @@ use ArrayAccess;
|
||||
use LogicException;
|
||||
|
||||
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
|
||||
*
|
||||
|
@ -19,8 +19,4 @@ namespace Aviat\AnimeClient\Types;
|
||||
/**
|
||||
* Type representing an Anime object for display
|
||||
*/
|
||||
final class AnimeFormItem extends AbstractType {
|
||||
public $data;
|
||||
public $id;
|
||||
public $mal_id;
|
||||
}
|
||||
final class AnimeFormItem extends FormItem { }
|
||||
|
@ -19,12 +19,4 @@ namespace Aviat\AnimeClient\Types;
|
||||
/**
|
||||
* Type representing an Anime object for display
|
||||
*/
|
||||
final class AnimeFormItemData extends AbstractType {
|
||||
public $notes;
|
||||
public $private;
|
||||
public $progress;
|
||||
public $rating;
|
||||
public $reconsumeCount;
|
||||
public $reconsuming;
|
||||
public $status;
|
||||
}
|
||||
final class AnimeFormItemData extends FormItemData {}
|
||||
|
27
src/Types/FormItem.php
Normal file
27
src/Types/FormItem.php
Normal 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;
|
||||
}
|
||||
|
30
src/Types/FormItemData.php
Normal file
30
src/Types/FormItemData.php
Normal 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;
|
||||
}
|
23
src/Types/MangaFormItem.php
Normal file
23
src/Types/MangaFormItem.php
Normal 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 { }
|
||||
|
19
src/Types/MangaFormItemData.php
Normal file
19
src/Types/MangaFormItemData.php
Normal 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 {}
|
40
src/Types/MangaListItem.php
Normal file
40
src/Types/MangaListItem.php
Normal 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;
|
||||
}
|
||||
|
31
src/Types/MangaListItemDetail.php
Normal file
31
src/Types/MangaListItemDetail.php
Normal 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
35
src/Types/MangaPage.php
Normal 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;
|
||||
}
|
@ -19,6 +19,10 @@ namespace Aviat\AnimeClient\Tests\API\Kitsu\Transformer;
|
||||
use Aviat\AnimeClient\API\JsonAPI;
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\AnimeClient\Types\{
|
||||
MangaFormItem,
|
||||
MangaFormItemData,
|
||||
};
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
@ -82,18 +86,18 @@ class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
];
|
||||
|
||||
$actual = $this->transformer->untransform($input);
|
||||
$expected = [
|
||||
$expected = new MangaFormItem([
|
||||
'id' => '15084773',
|
||||
'mal_id' => '26769',
|
||||
'data' => [
|
||||
'data' => new MangaFormItemData([
|
||||
'status' => 'current',
|
||||
'progress' => 67,
|
||||
'reconsuming' => false,
|
||||
'reconsumeCount' => 0,
|
||||
'notes' => '',
|
||||
'rating' => 4.5
|
||||
]
|
||||
];
|
||||
])
|
||||
]);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php return array (
|
||||
<?php return Aviat\AnimeClient\Types\AnimeListItem::__set_state(array(
|
||||
'id' => '15839442',
|
||||
'mal_id' => '33206',
|
||||
'episodes' =>
|
||||
@ -14,33 +14,40 @@
|
||||
'ended' => NULL,
|
||||
),
|
||||
'anime' =>
|
||||
array (
|
||||
'id' => '12243',
|
||||
Aviat\AnimeClient\Types\Anime::__set_state(array(
|
||||
'age_rating' => NULL,
|
||||
'title' => 'Kobayashi-san Chi no Maid Dragon',
|
||||
'titles' =>
|
||||
array (
|
||||
0 => 'Kobayashi-san Chi no Maid Dragon',
|
||||
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',
|
||||
'age_rating_guide' => NULL,
|
||||
'cover_image' => 'https://media.kitsu.io/anime/poster_images/12243/small.jpg?1481144116',
|
||||
'episode_count' => NULL,
|
||||
'episode_length' => NULL,
|
||||
'genres' =>
|
||||
array (
|
||||
0 => 'Comedy',
|
||||
1 => 'Fantasy',
|
||||
2 => 'Slice of Life',
|
||||
),
|
||||
'id' => '12243',
|
||||
'included' => NULL,
|
||||
'show_type' => 'TV',
|
||||
'slug' => 'kobayashi-san-chi-no-maid-dragon',
|
||||
'status' => NULL,
|
||||
'streaming_links' =>
|
||||
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',
|
||||
'notes' => NULL,
|
||||
'rewatching' => false,
|
||||
'rewatched' => 0,
|
||||
'user_rating' => '-',
|
||||
'private' => false,
|
||||
);
|
||||
));
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php return array (
|
||||
<?php return Aviat\AnimeClient\Types\AnimeFormItem::__set_state(array(
|
||||
'id' => 14047981,
|
||||
'mal_id' => NULL,
|
||||
'data' =>
|
||||
array (
|
||||
'status' => 'current',
|
||||
'reconsuming' => false,
|
||||
'reconsumeCount' => 0,
|
||||
Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array(
|
||||
'notes' => 'Very formulaic.',
|
||||
'progress' => 38,
|
||||
'private' => false,
|
||||
'progress' => 38,
|
||||
'rating' => 4,
|
||||
),
|
||||
);
|
||||
'reconsumeCount' => 0,
|
||||
'reconsuming' => false,
|
||||
'status' => 'current',
|
||||
)),
|
||||
));
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php return array (
|
||||
<?php return Aviat\AnimeClient\Types\AnimeFormItem::__set_state(array(
|
||||
'id' => 14047981,
|
||||
'mal_id' => '12345',
|
||||
'data' =>
|
||||
array (
|
||||
'status' => 'current',
|
||||
'reconsuming' => true,
|
||||
'reconsumeCount' => 0,
|
||||
Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array(
|
||||
'notes' => 'Very formulaic.',
|
||||
'progress' => 38,
|
||||
'private' => true,
|
||||
'progress' => 38,
|
||||
'rating' => 4,
|
||||
),
|
||||
);
|
||||
'reconsumeCount' => 0,
|
||||
'reconsuming' => true,
|
||||
'status' => 'current',
|
||||
)),
|
||||
));
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?php return array (
|
||||
<?php return Aviat\AnimeClient\Types\AnimeFormItem::__set_state(array(
|
||||
'id' => 14047983,
|
||||
'mal_id' => '12347',
|
||||
'data' =>
|
||||
array (
|
||||
'status' => 'current',
|
||||
'reconsuming' => true,
|
||||
'reconsumeCount' => 0,
|
||||
Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array(
|
||||
'notes' => '',
|
||||
'progress' => 12,
|
||||
'private' => true,
|
||||
),
|
||||
);
|
||||
'progress' => 12,
|
||||
'rating' => NULL,
|
||||
'reconsumeCount' => 0,
|
||||
'reconsuming' => true,
|
||||
'status' => 'current',
|
||||
)),
|
||||
));
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php return array (
|
||||
<?php return Aviat\AnimeClient\Types\Anime::__set_state(array(
|
||||
'age_rating' => 'R',
|
||||
'age_rating_guide' => 'Violence, Profanity',
|
||||
'cover_image' => 'https://media.kitsu.io/anime/poster_images/7442/small.jpg?1418580054',
|
||||
@ -8,6 +8,7 @@
|
||||
array (
|
||||
),
|
||||
'id' => 32344,
|
||||
'included' => NULL,
|
||||
'show_type' => 'TV',
|
||||
'slug' => 'attack-on-titan',
|
||||
'status' => 'Finished Airing',
|
||||
@ -92,10 +93,9 @@
|
||||
'title' => 'Attack on Titan',
|
||||
'titles' =>
|
||||
array (
|
||||
0 => 'Attack on Titan',
|
||||
1 => 'Shingeki no Kyojin',
|
||||
2 => '進撃の巨人',
|
||||
0 => 'Shingeki no Kyojin',
|
||||
1 => '進撃の巨人',
|
||||
),
|
||||
'trailer_id' => 'n4Nj6Y_SNYI',
|
||||
'url' => 'https://kitsu.io/anime/attack-on-titan',
|
||||
);
|
||||
));
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php return array (
|
||||
0 =>
|
||||
array (
|
||||
Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
|
||||
'id' => '15084773',
|
||||
'mal_id' => '26769',
|
||||
'chapters' =>
|
||||
@ -14,17 +14,7 @@
|
||||
'total' => '-',
|
||||
),
|
||||
'manga' =>
|
||||
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',
|
||||
Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
|
||||
'genres' =>
|
||||
array (
|
||||
0 => 'Comedy',
|
||||
@ -33,15 +23,24 @@
|
||||
3 => 'Slice of Life',
|
||||
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',
|
||||
'notes' => '',
|
||||
'rereading' => false,
|
||||
'reread' => 0,
|
||||
'user_rating' => 9.0,
|
||||
),
|
||||
)),
|
||||
1 =>
|
||||
array (
|
||||
Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
|
||||
'id' => '15085607',
|
||||
'mal_id' => '16',
|
||||
'chapters' =>
|
||||
@ -55,17 +54,7 @@
|
||||
'total' => 14,
|
||||
),
|
||||
'manga' =>
|
||||
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',
|
||||
Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
|
||||
'genres' =>
|
||||
array (
|
||||
0 => 'Comedy',
|
||||
@ -74,15 +63,24 @@
|
||||
3 => 'Romance',
|
||||
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',
|
||||
'notes' => '',
|
||||
'rereading' => false,
|
||||
'reread' => 0,
|
||||
'user_rating' => 7.0,
|
||||
),
|
||||
)),
|
||||
2 =>
|
||||
array (
|
||||
Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
|
||||
'id' => '15084529',
|
||||
'mal_id' => '35003',
|
||||
'chapters' =>
|
||||
@ -96,18 +94,7 @@
|
||||
'total' => '-',
|
||||
),
|
||||
'manga' =>
|
||||
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',
|
||||
Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
|
||||
'genres' =>
|
||||
array (
|
||||
0 => 'Comedy',
|
||||
@ -118,15 +105,25 @@
|
||||
5 => 'Sports',
|
||||
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',
|
||||
'notes' => '',
|
||||
'rereading' => false,
|
||||
'reread' => 0,
|
||||
'user_rating' => 9.0,
|
||||
),
|
||||
)),
|
||||
3 =>
|
||||
array (
|
||||
Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
|
||||
'id' => '15312827',
|
||||
'mal_id' => '78523',
|
||||
'chapters' =>
|
||||
@ -140,32 +137,31 @@
|
||||
'total' => '-',
|
||||
),
|
||||
'manga' =>
|
||||
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',
|
||||
Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
|
||||
'genres' =>
|
||||
array (
|
||||
0 => 'Romance',
|
||||
1 => 'School',
|
||||
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',
|
||||
'notes' => '',
|
||||
'rereading' => false,
|
||||
'reread' => 0,
|
||||
'user_rating' => '-',
|
||||
),
|
||||
)),
|
||||
4 =>
|
||||
array (
|
||||
Aviat\AnimeClient\Types\MangaListItem::__set_state(array(
|
||||
'id' => '15084769',
|
||||
'mal_id' => '60815',
|
||||
'chapters' =>
|
||||
@ -179,28 +175,27 @@
|
||||
'total' => '-',
|
||||
),
|
||||
'manga' =>
|
||||
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',
|
||||
Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array(
|
||||
'genres' =>
|
||||
array (
|
||||
0 => 'Comedy',
|
||||
1 => 'School',
|
||||
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',
|
||||
'notes' => '',
|
||||
'rereading' => false,
|
||||
'reread' => 0,
|
||||
'user_rating' => 8.0,
|
||||
),
|
||||
)),
|
||||
);
|
||||
|
@ -1,21 +1,17 @@
|
||||
<?php return 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',
|
||||
<?php return Aviat\AnimeClient\Types\MangaPage::__set_state(array(
|
||||
'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',
|
||||
'cover_image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
|
||||
'en_title' => NULL,
|
||||
'genres' =>
|
||||
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' => '-',
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user