Fixes for 4.1 #14

Merged
timw4mail merged 16 commits from develop into master 2018-12-13 14:51:01 -05:00
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))
{
$animeStats = [
'Time spent watching anime:' => $this->formatAnimeTime($stats['anime-amount-consumed']['time']), 'Time spent watching anime:' => $this->formatAnimeTime($stats['anime-amount-consumed']['time']),
'Anime series watched:' => number_format($stats['anime-amount-consumed']['media']), 'Anime series watched:' => number_format($stats['anime-amount-consumed']['media']),
'Anime episodes watched:' => number_format($stats['anime-amount-consumed']['units']), 'Anime episodes watched:' => number_format($stats['anime-amount-consumed']['units']),
];
}
if (array_key_exists('manga-amount-consumed', $stats))
{
$mangaStats = [
'Manga series read:' => number_format($stats['manga-amount-consumed']['media']), 'Manga series read:' => number_format($stats['manga-amount-consumed']['media']),
'Manga chapters read:' => number_format($stats['manga-amount-consumed']['units']), 'Manga chapters read:' => number_format($stats['manga-amount-consumed']['units']),
];
}
if ( ! empty($data))
{
$otherStats = [
'Posts:' => number_format($data['postsCount']), 'Posts:' => number_format($data['postsCount']),
'Comments:' => number_format($data['commentsCount']), 'Comments:' => number_format($data['commentsCount']),
'Media Rated:' => number_format($data['ratingsCount']), 'Media Rated:' => number_format($data['ratingsCount']),
]; ];
} }
return array_merge($animeStats, $mangaStats, $otherStats);
}
} }