Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
2 changed files with 34 additions and 15 deletions
Showing only changes of commit a38c9712e6 - Show all commits

View File

@ -27,10 +27,10 @@ use Aviat\AnimeClient\API\Kitsu;
</div> </div>
</section> </section>
<?php if (array_key_exists('anime', $data['media']) || array_key_exists('manga', $data['media'])): ?> <?php if ( ! (empty($data['media']['anime']) || empty($data['media']['manga']))): ?>
<h3>Media</h3> <h3>Media</h3>
<div class="tabs"> <div class="tabs">
<?php if (array_key_exists('anime', $data['media'])): ?> <?php if ( ! empty($data['media']['anime'])): ?>
<input checked="checked" type="radio" id="media-anime" name="media-tabs" /> <input checked="checked" type="radio" id="media-anime" name="media-tabs" />
<label for="media-anime">Anime</label> <label for="media-anime">Anime</label>
@ -58,7 +58,7 @@ use Aviat\AnimeClient\API\Kitsu;
</section> </section>
<?php endif ?> <?php endif ?>
<?php if (array_key_exists('manga', $data['media'])): ?> <?php if ( ! empty($data['media']['manga'])): ?>
<input type="radio" id="media-manga" name="media-tabs" /> <input type="radio" id="media-manga" name="media-tabs" />
<label for="media-manga">Manga</label> <label for="media-manga">Manga</label>

View File

@ -131,19 +131,38 @@ final class UserTransformer extends AbstractTransformer {
return $output; return $output;
} }
private function organizeStats($stats, $data): array private function organizeStats($stats, $data = []): array
{ {
// $timeOnAnime = $this->formatAnimeTime($orgData['attributes']['lifeSpentOnAnime']); $animeStats = [];
$mangaStats = [];
$otherStats = [];
return [ if (array_key_exists('anime-amount-consumed', $stats))
'Time spent watching anime:' => $this->formatAnimeTime($stats['anime-amount-consumed']['time']), {
'Anime series watched:' => number_format($stats['anime-amount-consumed']['media']), $animeStats = [
'Anime episodes watched:' => number_format($stats['anime-amount-consumed']['units']), 'Time spent watching anime:' => $this->formatAnimeTime($stats['anime-amount-consumed']['time']),
'Manga series read:' => number_format($stats['manga-amount-consumed']['media']), 'Anime series watched:' => number_format($stats['anime-amount-consumed']['media']),
'Manga chapters read:' => number_format($stats['manga-amount-consumed']['units']), 'Anime episodes watched:' => number_format($stats['anime-amount-consumed']['units']),
'Posts:' => number_format($data['postsCount']), ];
'Comments:' => number_format($data['commentsCount']), }
'Media Rated:' => number_format($data['ratingsCount']),
]; if (array_key_exists('manga-amount-consumed', $stats))
{
$mangaStats = [
'Manga series read:' => number_format($stats['manga-amount-consumed']['media']),
'Manga chapters read:' => number_format($stats['manga-amount-consumed']['units']),
];
}
if ( ! empty($data))
{
$otherStats = [
'Posts:' => number_format($data['postsCount']),
'Comments:' => number_format($data['commentsCount']),
'Media Rated:' => number_format($data['ratingsCount']),
];
}
return array_merge($animeStats, $mangaStats, $otherStats);
} }
} }