diff --git a/phpunit.xml b/phpunit.xml index d5fc7e52..5a0d5699 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,8 +9,5 @@ ./test/JikanTest - - ./test/JikanTest/JikanTest.php - diff --git a/src/Helper/Constants.php b/src/Helper/Constants.php index 99271d18..5e32b6df 100644 --- a/src/Helper/Constants.php +++ b/src/Helper/Constants.php @@ -49,10 +49,6 @@ class Constants public const TOP_BY_POPULARITY = 'bypopularity'; public const TOP_BY_FAVORITES = 'favorite'; - public const RECENT_REVIEW_ANIME = 'anime'; - public const RECENT_REVIEW_MANGA = 'manga'; - public const RECENT_REVIEW_BEST_VOTED = 'bestvoted'; - public const RECENT_RECOMMENDATION_ANIME = 'anime'; public const RECENT_RECOMMENDATION_MANGA = 'manga'; @@ -306,4 +302,8 @@ class Constants public const USER_LIST_SORT_DESCENDING = 1; public const USER_LIST_SORT_ASCENDING = -1; + + public const REVIEWS_SORT_MOST_VOTED = 'mostvoted'; + public const REVIEWS_SORT_OLDEST = 'oldest'; + public const REVIEWS_SORT_NEWEST = 'newest'; } diff --git a/src/Model/Anime/Anime.php b/src/Model/Anime/Anime.php index 9a80022a..0479920f 100755 --- a/src/Model/Anime/Anime.php +++ b/src/Model/Anime/Anime.php @@ -16,7 +16,6 @@ */ class Anime { - /** * @var int */ diff --git a/src/Model/Anime/AnimeEpisode.php b/src/Model/Anime/AnimeEpisode.php index ed9a80ff..617d9c61 100644 --- a/src/Model/Anime/AnimeEpisode.php +++ b/src/Model/Anime/AnimeEpisode.php @@ -11,7 +11,6 @@ */ class AnimeEpisode { - /** * @var int */ diff --git a/src/Model/Anime/AnimeReview.php b/src/Model/Anime/AnimeReview.php index 191da679..7db7e305 100644 --- a/src/Model/Anime/AnimeReview.php +++ b/src/Model/Anime/AnimeReview.php @@ -16,7 +16,7 @@ class AnimeReview extends \Jikan\Model\Reviews\AnimeReview /** * @var Reviewer */ - private $user; + private Reviewer $user; /** * @param AnimeReviewParser $parser @@ -30,32 +30,19 @@ public static function fromParser(AnimeReviewParser $parser): AnimeReview $instance->malId = $parser->getId(); $instance->url = $parser->getUrl(); $instance->type = $parser->getType() ?? 'anime'; - $instance->votes = $parser->getHelpfulCount(); + $instance->reactions = $parser->getReactions(); $instance->date = $parser->getDate(); $instance->user = $parser->getReviewer(); - $instance->scores = $parser->getAnimeScores(); + $instance->score = $parser->getReviewerScore(); $instance->review = $parser->getContent(); + $instance->tags = $parser->getReviewTag(); + $instance->isPreliminary = $parser->isPreliminary(); $instance->episodesWatched = $parser->getEpisodesWatched(); + $instance->isSpoiler = $parser->isSpoiler(); return $instance; } - /** - * @return string - */ - public function getEpisodesWatched(): string - { - return $this->episodesWatched; - } - - /** - * @return AnimeReviewScores - */ - public function getScores(): AnimeReviewScores - { - return $this->scores; - } - /** * @return Reviewer */ @@ -63,52 +50,4 @@ public function getUser(): Reviewer { return $this->user; } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } } diff --git a/src/Model/Anime/AnimeReviewScores.php b/src/Model/Anime/AnimeReviewScores.php index c1466cb8..0c6596d9 100644 --- a/src/Model/Anime/AnimeReviewScores.php +++ b/src/Model/Anime/AnimeReviewScores.php @@ -11,7 +11,6 @@ */ class AnimeReviewScores { - /** * @var int */ diff --git a/src/Model/Anime/AnimeReviews.php b/src/Model/Anime/AnimeReviews.php index e9f04e34..bc521a91 100644 --- a/src/Model/Anime/AnimeReviews.php +++ b/src/Model/Anime/AnimeReviews.php @@ -8,7 +8,6 @@ class AnimeReviews extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Anime/AnimeUserUpdates.php b/src/Model/Anime/AnimeUserUpdates.php index 6665ba0a..4138595c 100644 --- a/src/Model/Anime/AnimeUserUpdates.php +++ b/src/Model/Anime/AnimeUserUpdates.php @@ -13,7 +13,6 @@ */ class AnimeUserUpdates extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Anime/AnimeVideosEpisodes.php b/src/Model/Anime/AnimeVideosEpisodes.php index bc24ec41..3552295a 100644 --- a/src/Model/Anime/AnimeVideosEpisodes.php +++ b/src/Model/Anime/AnimeVideosEpisodes.php @@ -13,7 +13,6 @@ */ class AnimeVideosEpisodes extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Anime/Episodes.php b/src/Model/Anime/Episodes.php index 0e270894..9927a5d2 100644 --- a/src/Model/Anime/Episodes.php +++ b/src/Model/Anime/Episodes.php @@ -4,7 +4,7 @@ use Jikan\Model\Common\Collection\Pagination; use Jikan\Model\Common\Collection\Results; -use Jikan\Model\Reviews\RecentReviews; +use Jikan\Model\Reviews\Reviews; use Jikan\Parser\Anime\EpisodesParser; /** @@ -14,7 +14,6 @@ */ class Episodes extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Character/VoiceActor.php b/src/Model/Character/VoiceActor.php index e0e26fae..09027b4b 100644 --- a/src/Model/Character/VoiceActor.php +++ b/src/Model/Character/VoiceActor.php @@ -12,7 +12,6 @@ */ class VoiceActor { - /** * @var PersonMeta */ diff --git a/src/Model/Club/Club.php b/src/Model/Club/Club.php index ecd248cc..b642d0aa 100644 --- a/src/Model/Club/Club.php +++ b/src/Model/Club/Club.php @@ -13,7 +13,6 @@ */ class Club { - /** * @var int */ diff --git a/src/Model/Common/AnimeMeta.php b/src/Model/Common/AnimeMeta.php index 3ecf1e24..f4d68f4d 100644 --- a/src/Model/Common/AnimeMeta.php +++ b/src/Model/Common/AnimeMeta.php @@ -15,22 +15,22 @@ class AnimeMeta /** * @var int */ - private $malId; + private int $malId; /** * @var string */ - private $url; + private string $url; /** * @var CommonImageResource */ - private $images; + private CommonImageResource $images; /** * @var string */ - private $title; + private string $title; /** * Genre constructor. diff --git a/src/Model/Common/ClubMeta.php b/src/Model/Common/ClubMeta.php index 0555aacd..3402587a 100644 --- a/src/Model/Common/ClubMeta.php +++ b/src/Model/Common/ClubMeta.php @@ -9,7 +9,6 @@ */ class ClubMeta { - /** * @var int */ diff --git a/src/Model/Common/MusicMeta.php b/src/Model/Common/MusicMeta.php index 66bee4b7..07ee27f8 100644 --- a/src/Model/Common/MusicMeta.php +++ b/src/Model/Common/MusicMeta.php @@ -9,7 +9,6 @@ */ class MusicMeta { - /** * @var string|null */ diff --git a/src/Model/Common/Recommendation.php b/src/Model/Common/Recommendation.php index c1650fd9..ee419619 100644 --- a/src/Model/Common/Recommendation.php +++ b/src/Model/Common/Recommendation.php @@ -14,7 +14,6 @@ */ class Recommendation { - /** * @var CommonMeta */ diff --git a/src/Model/Common/User.php b/src/Model/Common/User.php index 0b2cfbea..4d9b2ca5 100644 --- a/src/Model/Common/User.php +++ b/src/Model/Common/User.php @@ -9,7 +9,6 @@ */ abstract class User { - /** * @var string */ diff --git a/src/Model/Genre/AnimeGenre.php b/src/Model/Genre/AnimeGenre.php index 7f0a6b33..9a5f350d 100644 --- a/src/Model/Genre/AnimeGenre.php +++ b/src/Model/Genre/AnimeGenre.php @@ -15,7 +15,6 @@ */ class AnimeGenre extends Results implements Pagination { - /** * @var int */ diff --git a/src/Model/Genre/AnimeGenreList.php b/src/Model/Genre/AnimeGenreList.php index ac3f9795..852b4d50 100644 --- a/src/Model/Genre/AnimeGenreList.php +++ b/src/Model/Genre/AnimeGenreList.php @@ -13,7 +13,6 @@ */ class AnimeGenreList { - /** * @var array|AnimeGenreListItem[] */ diff --git a/src/Model/Genre/MangaGenreList.php b/src/Model/Genre/MangaGenreList.php index c669b156..39d7a7b6 100644 --- a/src/Model/Genre/MangaGenreList.php +++ b/src/Model/Genre/MangaGenreList.php @@ -13,7 +13,6 @@ */ class MangaGenreList { - /** * @var array|MangaGenreListItem[] */ diff --git a/src/Model/Genre/MangaGenreListItem.php b/src/Model/Genre/MangaGenreListItem.php index fa7faec6..bec73fb8 100644 --- a/src/Model/Genre/MangaGenreListItem.php +++ b/src/Model/Genre/MangaGenreListItem.php @@ -12,7 +12,6 @@ */ class MangaGenreListItem { - /** * @var int */ diff --git a/src/Model/Magazine/Magazine.php b/src/Model/Magazine/Magazine.php index 853d159e..dfed7504 100644 --- a/src/Model/Magazine/Magazine.php +++ b/src/Model/Magazine/Magazine.php @@ -14,7 +14,6 @@ */ class Magazine extends Results implements Pagination { - /** * @var int */ diff --git a/src/Model/Magazine/MagazineList.php b/src/Model/Magazine/MagazineList.php index 51efc5ec..c5bc3dd6 100644 --- a/src/Model/Magazine/MagazineList.php +++ b/src/Model/Magazine/MagazineList.php @@ -13,7 +13,6 @@ */ class MagazineList { - /** * @var array|MagazineListItem[] */ diff --git a/src/Model/Manga/Manga.php b/src/Model/Manga/Manga.php index fecc2842..4518ce95 100755 --- a/src/Model/Manga/Manga.php +++ b/src/Model/Manga/Manga.php @@ -22,7 +22,6 @@ */ class Manga { - /** * @var int */ diff --git a/src/Model/Manga/MangaReview.php b/src/Model/Manga/MangaReview.php index c1a06d48..0a031686 100644 --- a/src/Model/Manga/MangaReview.php +++ b/src/Model/Manga/MangaReview.php @@ -13,11 +13,10 @@ */ class MangaReview extends \Jikan\Model\Reviews\MangaReview { - /** * @var Reviewer */ - private $user; + private Reviewer $user; /** @@ -32,32 +31,19 @@ public static function fromParser(MangaReviewParser $parser): MangaReview $instance->malId = $parser->getId(); $instance->url = $parser->getUrl(); $instance->type = $parser->getType() ?? 'manga'; - $instance->votes = $parser->getHelpfulCount(); + $instance->reactions = $parser->getReactions(); $instance->date = $parser->getDate(); $instance->user = $parser->getReviewer(); - $instance->scores = $parser->getMangaScores(); + $instance->score = $parser->getReviewerScore(); $instance->review = $parser->getContent(); + $instance->tags = $parser->getReviewTag(); + $instance->isPreliminary = $parser->isPreliminary(); $instance->chaptersRead = $parser->getChaptersRead(); + $instance->isSpoiler = $parser->isSpoiler(); return $instance; } - /** - * @return string - */ - public function getChaptersRead(): string - { - return $this->chaptersRead; - } - - /** - * @return MangaReviewScores - */ - public function getScores(): MangaReviewScores - { - return $this->scores; - } - /** * @return Reviewer */ @@ -65,52 +51,4 @@ public function getUser(): Reviewer { return $this->user; } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } } diff --git a/src/Model/Manga/MangaReviewScores.php b/src/Model/Manga/MangaReviewScores.php index 4e17518d..6f38425d 100644 --- a/src/Model/Manga/MangaReviewScores.php +++ b/src/Model/Manga/MangaReviewScores.php @@ -11,7 +11,6 @@ */ class MangaReviewScores { - /** * @var int */ diff --git a/src/Model/Manga/MangaReviewer.php b/src/Model/Manga/MangaReviewer.php index 7e8d9cdc..a3bc65f1 100644 --- a/src/Model/Manga/MangaReviewer.php +++ b/src/Model/Manga/MangaReviewer.php @@ -13,7 +13,6 @@ */ class MangaReviewer extends Reviewer { - /** * @var int */ diff --git a/src/Model/Manga/MangaReviews.php b/src/Model/Manga/MangaReviews.php index 8a90f0fd..1e5ea08f 100644 --- a/src/Model/Manga/MangaReviews.php +++ b/src/Model/Manga/MangaReviews.php @@ -8,7 +8,6 @@ class MangaReviews extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Manga/MangaUserUpdates.php b/src/Model/Manga/MangaUserUpdates.php index 96219b95..fd23c84c 100644 --- a/src/Model/Manga/MangaUserUpdates.php +++ b/src/Model/Manga/MangaUserUpdates.php @@ -13,7 +13,6 @@ */ class MangaUserUpdates extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/News/NewsList.php b/src/Model/News/NewsList.php index caabf289..48a0cb50 100644 --- a/src/Model/News/NewsList.php +++ b/src/Model/News/NewsList.php @@ -13,7 +13,6 @@ */ class NewsList extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Producer/Producer.php b/src/Model/Producer/Producer.php index 043d2ab7..0a0d46b7 100644 --- a/src/Model/Producer/Producer.php +++ b/src/Model/Producer/Producer.php @@ -18,7 +18,6 @@ */ class Producer extends Results implements Pagination { - /** * @var int */ diff --git a/src/Model/Producer/ProducerList.php b/src/Model/Producer/ProducerList.php index 2dfd71ab..1c9e9533 100644 --- a/src/Model/Producer/ProducerList.php +++ b/src/Model/Producer/ProducerList.php @@ -12,7 +12,6 @@ */ class ProducerList { - /** * @var array|ProducerListItem[] */ diff --git a/src/Model/Recommendations/RecentRecommendations.php b/src/Model/Recommendations/RecentRecommendations.php index 96d04f36..3ac0150f 100644 --- a/src/Model/Recommendations/RecentRecommendations.php +++ b/src/Model/Recommendations/RecentRecommendations.php @@ -10,11 +10,10 @@ /** * Class RecentRecommendations * - * @package Jikan\Model\UserReviewsParser\RecentReviews + * @package Jikan\Model\UserReviewsParser\Reviews */ class RecentRecommendations extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Recommendations/UserRecommendations.php b/src/Model/Recommendations/UserRecommendations.php index fb5cdad3..d3ae6595 100644 --- a/src/Model/Recommendations/UserRecommendations.php +++ b/src/Model/Recommendations/UserRecommendations.php @@ -9,11 +9,10 @@ /** * Class UserRecommendations * - * @package Jikan\Model\UserReviewsParser\RecentReviews + * @package Jikan\Model\UserReviewsParser\Reviews */ class UserRecommendations extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Resource/AnimeImageResource/AnimeImageResource.php b/src/Model/Resource/AnimeImageResource/AnimeImageResource.php index 150a9146..90cec496 100644 --- a/src/Model/Resource/AnimeImageResource/AnimeImageResource.php +++ b/src/Model/Resource/AnimeImageResource/AnimeImageResource.php @@ -8,7 +8,6 @@ */ class AnimeImageResource { - /** * @var Jpg */ diff --git a/src/Model/Resource/AnimeImageResource/Jpg.php b/src/Model/Resource/AnimeImageResource/Jpg.php index d01fa8d8..52a193d8 100644 --- a/src/Model/Resource/AnimeImageResource/Jpg.php +++ b/src/Model/Resource/AnimeImageResource/Jpg.php @@ -8,7 +8,6 @@ */ class Jpg { - /** * @var string|null */ diff --git a/src/Model/Resource/AnimeImageResource/Webp.php b/src/Model/Resource/AnimeImageResource/Webp.php index b5fbfbe4..d6b99dfb 100644 --- a/src/Model/Resource/AnimeImageResource/Webp.php +++ b/src/Model/Resource/AnimeImageResource/Webp.php @@ -8,7 +8,6 @@ */ class Webp { - /** * @var string|null */ diff --git a/src/Model/Resource/CharacterImageResource/CharacterImageResource.php b/src/Model/Resource/CharacterImageResource/CharacterImageResource.php index 83468a32..22c440ad 100644 --- a/src/Model/Resource/CharacterImageResource/CharacterImageResource.php +++ b/src/Model/Resource/CharacterImageResource/CharacterImageResource.php @@ -8,7 +8,6 @@ */ class CharacterImageResource { - /** * @var Jpg */ diff --git a/src/Model/Resource/CharacterImageResource/Jpg.php b/src/Model/Resource/CharacterImageResource/Jpg.php index 9ccf8481..f8f5de25 100644 --- a/src/Model/Resource/CharacterImageResource/Jpg.php +++ b/src/Model/Resource/CharacterImageResource/Jpg.php @@ -8,7 +8,6 @@ */ class Jpg { - /** * @var string|null */ diff --git a/src/Model/Resource/CharacterImageResource/Webp.php b/src/Model/Resource/CharacterImageResource/Webp.php index dc3777ae..2163b763 100644 --- a/src/Model/Resource/CharacterImageResource/Webp.php +++ b/src/Model/Resource/CharacterImageResource/Webp.php @@ -8,7 +8,6 @@ */ class Webp { - /** * @var string|null */ diff --git a/src/Model/Resource/ClubImageResource/ClubImageResource.php b/src/Model/Resource/ClubImageResource/ClubImageResource.php index 64c64a8b..56acce18 100644 --- a/src/Model/Resource/ClubImageResource/ClubImageResource.php +++ b/src/Model/Resource/ClubImageResource/ClubImageResource.php @@ -8,7 +8,6 @@ */ class ClubImageResource { - /** * @var Jpg */ diff --git a/src/Model/Resource/ClubImageResource/Jpg.php b/src/Model/Resource/ClubImageResource/Jpg.php index 9667d3af..a3d5c877 100644 --- a/src/Model/Resource/ClubImageResource/Jpg.php +++ b/src/Model/Resource/ClubImageResource/Jpg.php @@ -8,7 +8,6 @@ */ class Jpg { - /** * @var string|null */ diff --git a/src/Model/Resource/CommonImageResource/CommonImageResource.php b/src/Model/Resource/CommonImageResource/CommonImageResource.php index d7e63a18..42c068ae 100644 --- a/src/Model/Resource/CommonImageResource/CommonImageResource.php +++ b/src/Model/Resource/CommonImageResource/CommonImageResource.php @@ -8,7 +8,6 @@ */ class CommonImageResource { - /** * @var Jpg */ diff --git a/src/Model/Resource/CommonImageResource/Jpg.php b/src/Model/Resource/CommonImageResource/Jpg.php index 30663aa3..69944061 100644 --- a/src/Model/Resource/CommonImageResource/Jpg.php +++ b/src/Model/Resource/CommonImageResource/Jpg.php @@ -8,7 +8,6 @@ */ class Jpg { - /** * @var string|null */ diff --git a/src/Model/Resource/CommonImageResource/Webp.php b/src/Model/Resource/CommonImageResource/Webp.php index 87188109..739a95bc 100644 --- a/src/Model/Resource/CommonImageResource/Webp.php +++ b/src/Model/Resource/CommonImageResource/Webp.php @@ -8,7 +8,6 @@ */ class Webp { - /** * @var string|null */ diff --git a/src/Model/Resource/PersonImageResource/Jpg.php b/src/Model/Resource/PersonImageResource/Jpg.php index 358defcb..a7305c4d 100644 --- a/src/Model/Resource/PersonImageResource/Jpg.php +++ b/src/Model/Resource/PersonImageResource/Jpg.php @@ -8,7 +8,6 @@ */ class Jpg { - /** * @var string|null */ diff --git a/src/Model/Resource/PersonImageResource/PersonImageResource.php b/src/Model/Resource/PersonImageResource/PersonImageResource.php index 37ae4236..5edc5124 100644 --- a/src/Model/Resource/PersonImageResource/PersonImageResource.php +++ b/src/Model/Resource/PersonImageResource/PersonImageResource.php @@ -8,7 +8,6 @@ */ class PersonImageResource { - /** * @var Jpg */ diff --git a/src/Model/Resource/UserImageResource/Jpg.php b/src/Model/Resource/UserImageResource/Jpg.php index 5f569e76..be47e0aa 100644 --- a/src/Model/Resource/UserImageResource/Jpg.php +++ b/src/Model/Resource/UserImageResource/Jpg.php @@ -8,7 +8,6 @@ */ class Jpg { - /** * @var string|null */ diff --git a/src/Model/Resource/UserImageResource/UserImageResource.php b/src/Model/Resource/UserImageResource/UserImageResource.php index 3118f8d7..beca6ab4 100644 --- a/src/Model/Resource/UserImageResource/UserImageResource.php +++ b/src/Model/Resource/UserImageResource/UserImageResource.php @@ -8,7 +8,6 @@ */ class UserImageResource { - /** * @var Jpg */ diff --git a/src/Model/Resource/UserImageResource/Webp.php b/src/Model/Resource/UserImageResource/Webp.php index b26ead3e..dc99c731 100644 --- a/src/Model/Resource/UserImageResource/Webp.php +++ b/src/Model/Resource/UserImageResource/Webp.php @@ -8,7 +8,6 @@ */ class Webp { - /** * @var string|null */ diff --git a/src/Model/Resource/WrapImageResource/Jpg.php b/src/Model/Resource/WrapImageResource/Jpg.php index 3e8238e8..207f154d 100644 --- a/src/Model/Resource/WrapImageResource/Jpg.php +++ b/src/Model/Resource/WrapImageResource/Jpg.php @@ -8,7 +8,6 @@ */ class Jpg { - /** * @var string|null */ diff --git a/src/Model/Resource/WrapImageResource/WrapImageResource.php b/src/Model/Resource/WrapImageResource/WrapImageResource.php index c5e31e7d..60967b58 100644 --- a/src/Model/Resource/WrapImageResource/WrapImageResource.php +++ b/src/Model/Resource/WrapImageResource/WrapImageResource.php @@ -8,7 +8,6 @@ */ class WrapImageResource { - /** * @var Jpg */ diff --git a/src/Model/Resource/YoutubeImageResource.php b/src/Model/Resource/YoutubeImageResource.php index c5b59ff8..d208a463 100644 --- a/src/Model/Resource/YoutubeImageResource.php +++ b/src/Model/Resource/YoutubeImageResource.php @@ -8,7 +8,6 @@ */ class YoutubeImageResource { - /** * @var string|null */ diff --git a/src/Model/Reviews/AnimeReview.php b/src/Model/Reviews/AnimeReview.php index e4b9d2fe..9bda05e8 100644 --- a/src/Model/Reviews/AnimeReview.php +++ b/src/Model/Reviews/AnimeReview.php @@ -11,78 +11,16 @@ */ abstract class AnimeReview extends Review { - /** - * @var string + * @var int|null */ - protected $episodesWatched; + protected ?int $episodesWatched; /** - * @var AnimeReviewScores + * @return int|null */ - protected $scores; - - /** - * @return string - */ - public function getEpisodesWatched(): string + public function getEpisodesWatched(): ?int { return $this->episodesWatched; } - - /** - * @return AnimeReviewScores - */ - public function getScores(): AnimeReviewScores - { - return $this->scores; - } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } } diff --git a/src/Model/Reviews/FullAnimeReview.php b/src/Model/Reviews/FullAnimeReview.php new file mode 100644 index 00000000..02971ef0 --- /dev/null +++ b/src/Model/Reviews/FullAnimeReview.php @@ -0,0 +1,67 @@ +entry = $parser->getAnime(); + $instance->malId = $parser->getId(); + $instance->url = $parser->getUrl(); + $instance->type = $parser->getType(); + $instance->reactions = $parser->getReactions(); + $instance->date = $parser->getDate(); + $instance->user = $parser->getReviewer(); + $instance->score = $parser->getReviewerScore(); + $instance->review = $parser->getContent(); + $instance->tags = $parser->getReviewTag(); + $instance->isPreliminary = $parser->isPreliminary(); + $instance->episodesWatched = $parser->getEpisodesWatched(); + $instance->isSpoiler = $parser->isSpoiler(); + + return $instance; + } + + /** + * @return AnimeMeta + */ + public function getEntry(): AnimeMeta + { + return $this->entry; + } + + /** + * @return Reviewer + */ + public function getUser(): Reviewer + { + return $this->user; + } +} diff --git a/src/Model/Reviews/FullMangaReview.php b/src/Model/Reviews/FullMangaReview.php new file mode 100644 index 00000000..58d41d1a --- /dev/null +++ b/src/Model/Reviews/FullMangaReview.php @@ -0,0 +1,72 @@ +entry = $parser->getManga(); + $instance->malId = $parser->getId(); + $instance->url = $parser->getUrl(); + $instance->type = $parser->getType() ?? 'manga'; + $instance->reactions = $parser->getReactions(); + $instance->date = $parser->getDate(); + $instance->user = $parser->getReviewer(); + $instance->score = $parser->getReviewerScore(); + $instance->review = $parser->getContent(); + $instance->tags = $parser->getReviewTag(); + $instance->isPreliminary = $parser->isPreliminary(); + $instance->chaptersRead = $parser->getChaptersRead(); + $instance->isSpoiler = $parser->isSpoiler(); + + return $instance; + } + + /** + * @return MangaMeta + */ + public function getEntry(): MangaMeta + { + return $this->entry; + } + + /** + * @return Reviewer + */ + public function getUser(): Reviewer + { + return $this->user; + } +} diff --git a/src/Model/Reviews/MangaReview.php b/src/Model/Reviews/MangaReview.php index 51eb1e09..f9ecb8ff 100644 --- a/src/Model/Reviews/MangaReview.php +++ b/src/Model/Reviews/MangaReview.php @@ -2,8 +2,6 @@ namespace Jikan\Model\Reviews; -use Jikan\Model\Manga\MangaReviewScores; - /** * Class UserAnimeReview * @@ -11,78 +9,17 @@ */ abstract class MangaReview extends Review { - /** - * @var string + * @var int|null */ - protected $chaptersRead; + protected ?int $chaptersRead; - /** - * @var MangaReviewScores - */ - protected $scores; /** * @return string */ - public function getChaptersRead(): string + public function getChaptersRead(): ?string { return $this->chaptersRead; } - - /** - * @return MangaReviewScores - */ - public function getScores(): MangaReviewScores - { - return $this->scores; - } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } } diff --git a/src/Model/Reviews/Reactions.php b/src/Model/Reviews/Reactions.php new file mode 100644 index 00000000..f8bceaf7 --- /dev/null +++ b/src/Model/Reviews/Reactions.php @@ -0,0 +1,139 @@ +overall = $parser->getOverall(); + $instance->loveIt = $parser->getLoveIt(); + $instance->nice = $parser->getNice(); + $instance->funny = $parser->getFunny(); + $instance->confusing = $parser->getConfusing(); + $instance->informative = $parser->getInformative(); + $instance->wellWritten = $parser->getWellWritten(); + $instance->creative = $parser->getCreative(); + + return $instance; + } + + /** + * @return int + */ + public function getOverall(): int + { + return $this->overall; + } + + /** + * @return int + */ + public function getNice(): int + { + return $this->nice; + } + + /** + * @return int + */ + public function getLoveIt(): int + { + return $this->loveIt; + } + + /** + * @return int + */ + public function getFunny(): int + { + return $this->funny; + } + + /** + * @return int + */ + public function getConfusing(): int + { + return $this->confusing; + } + + /** + * @return int + */ + public function getInformative(): int + { + return $this->informative; + } + + /** + * @return int + */ + public function getWellWritten(): int + { + return $this->wellWritten; + } + + /** + * @return int + */ + public function getCreative(): int + { + return $this->creative; + } +} diff --git a/src/Model/Reviews/Recent/RecentAnimeReview.php b/src/Model/Reviews/Recent/RecentAnimeReview.php deleted file mode 100644 index eff59c44..00000000 --- a/src/Model/Reviews/Recent/RecentAnimeReview.php +++ /dev/null @@ -1,130 +0,0 @@ -entry = $parser->getAnime(); - $instance->malId = $parser->getId(); - $instance->url = $parser->getUrl(); - $instance->type = $parser->getType(); - $instance->votes = $parser->getHelpfulCount(); - $instance->date = $parser->getDate(); - $instance->user = $parser->getReviewer(); - $instance->scores = $parser->getAnimeScores(); - $instance->review = $parser->getContent(); - $instance->episodesWatched = $parser->getEpisodesWatched(); - - return $instance; - } - - /** - * @return string - */ - public function getEpisodesWatched(): string - { - return $this->episodesWatched; - } - - /** - * @return AnimeReviewScores - */ - public function getScores(): AnimeReviewScores - { - return $this->scores; - } - - /** - * @return AnimeMeta - */ - public function getEntry(): AnimeMeta - { - return $this->entry; - } - - /** - * @return Reviewer - */ - public function getUser(): Reviewer - { - return $this->user; - } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } -} diff --git a/src/Model/Reviews/Recent/RecentMangaReview.php b/src/Model/Reviews/Recent/RecentMangaReview.php deleted file mode 100644 index 209a2fb1..00000000 --- a/src/Model/Reviews/Recent/RecentMangaReview.php +++ /dev/null @@ -1,135 +0,0 @@ -entry = $parser->getManga(); - $instance->malId = $parser->getId(); - $instance->url = $parser->getUrl(); - $instance->type = $parser->getType(); - $instance->votes = $parser->getHelpfulCount(); - $instance->date = $parser->getDate(); - $instance->user = $parser->getReviewer(); - $instance->scores = $parser->getMangaScores(); - $instance->review = $parser->getContent(); - $instance->chaptersRead = $parser->getChaptersRead(); - - return $instance; - } - - /** - * @return string - */ - public function getChaptersRead(): string - { - return $this->chaptersRead; - } - - /** - * @return MangaReviewScores - */ - public function getScores(): MangaReviewScores - { - return $this->scores; - } - - /** - * @return MangaMeta - */ - public function getEntry(): MangaMeta - { - return $this->entry; - } - - /** - * @return Reviewer - */ - public function getUser(): Reviewer - { - return $this->user; - } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } -} diff --git a/src/Model/Reviews/Review.php b/src/Model/Reviews/Review.php index adead9b3..99235800 100644 --- a/src/Model/Reviews/Review.php +++ b/src/Model/Reviews/Review.php @@ -12,36 +12,55 @@ */ abstract class Review { - /** * @var int */ - protected $malId; + protected int $malId; /** * @var string */ - protected $url; + protected string $url; /** - * @var string + * @var string|null */ - protected $type; + protected ?string $type; /** - * @var int + * @var Reactions */ - protected $votes; + protected Reactions $reactions; /** * @var \DateTimeImmutable */ - protected $date; + protected \DateTimeImmutable $date; /** * @var string */ - protected $review; + protected string $review; + + /** + * @var int + */ + protected int $score; + + /** + * @var array + */ + protected array $tags; + + /** + * @var bool + */ + protected bool $isSpoiler; + + /** + * @var bool + */ + protected bool $isPreliminary; /** * @return int @@ -68,11 +87,11 @@ public function getType(): string } /** - * @return int + * @return Reactions */ - public function getVotes(): int + public function getReactions(): Reactions { - return $this->votes; + return $this->reactions; } /** @@ -90,4 +109,36 @@ public function getReview(): string { return $this->review; } + + /** + * @return int + */ + public function getScore(): int + { + return $this->score; + } + + /** + * @return array + */ + public function getTags(): array + { + return $this->tags; + } + + /** + * @return bool + */ + public function isSpoiler(): bool + { + return $this->isSpoiler; + } + + /** + * @return bool + */ + public function isPreliminary(): bool + { + return $this->isPreliminary; + } } diff --git a/src/Model/Reviews/Reviewer.php b/src/Model/Reviews/Reviewer.php index f67a1fe0..ede1f480 100644 --- a/src/Model/Reviews/Reviewer.php +++ b/src/Model/Reviews/Reviewer.php @@ -13,11 +13,10 @@ */ class Reviewer extends User { - /** * @var UserImageResource */ - protected $images; + protected UserImageResource $images; public static function fromParser(ReviewerParser $parser): self diff --git a/src/Model/Reviews/RecentReviews.php b/src/Model/Reviews/Reviews.php similarity index 74% rename from src/Model/Reviews/RecentReviews.php rename to src/Model/Reviews/Reviews.php index c9ef08cb..c19bb175 100644 --- a/src/Model/Reviews/RecentReviews.php +++ b/src/Model/Reviews/Reviews.php @@ -8,13 +8,12 @@ use Jikan\Parser; /** - * Class RecentReviews + * Class Reviews * - * @package Jikan\Model\UserReviewsParser\RecentReviews + * @package Jikan\Model\UserReviewsParser\Reviews */ -class RecentReviews extends Results implements Pagination +class Reviews extends Results implements Pagination { - /** * @var bool */ @@ -26,18 +25,18 @@ class RecentReviews extends Results implements Pagination private $lastVisiblePage = 1; /** - * @param Parser\Reviews\RecentReviewsParser $parser + * @param Parser\Reviews\ReviewsParser $parser * - * @return RecentReviews + * @return Reviews * @throws \Exception * @throws \RuntimeException * @throws \InvalidArgumentException */ - public static function fromParser(Parser\Reviews\RecentReviewsParser $parser): self + public static function fromParser(Parser\Reviews\ReviewsParser $parser): self { $instance = new self(); - $instance->results = $parser->getRecentReviews(); + $instance->results = $parser->getReviews(); $instance->hasNextPage = $parser->hasNextPage(); return $instance; diff --git a/src/Model/Schedule/Schedule.php b/src/Model/Schedule/Schedule.php index f4291857..c343cf1e 100755 --- a/src/Model/Schedule/Schedule.php +++ b/src/Model/Schedule/Schedule.php @@ -12,7 +12,6 @@ */ class Schedule { - /** * @var AnimeCard[] */ diff --git a/src/Model/Search/AnimeSearch.php b/src/Model/Search/AnimeSearch.php index f10870dd..c04f0621 100644 --- a/src/Model/Search/AnimeSearch.php +++ b/src/Model/Search/AnimeSearch.php @@ -13,7 +13,6 @@ */ class AnimeSearch extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Search/CharacterSearch.php b/src/Model/Search/CharacterSearch.php index 09017c4c..7bd85c88 100644 --- a/src/Model/Search/CharacterSearch.php +++ b/src/Model/Search/CharacterSearch.php @@ -13,7 +13,6 @@ */ class CharacterSearch extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Search/CharacterSearchListItem.php b/src/Model/Search/CharacterSearchListItem.php index fdc8f07a..0fb93b01 100644 --- a/src/Model/Search/CharacterSearchListItem.php +++ b/src/Model/Search/CharacterSearchListItem.php @@ -12,7 +12,6 @@ */ class CharacterSearchListItem { - /** * @var int */ diff --git a/src/Model/Search/MangaSearch.php b/src/Model/Search/MangaSearch.php index d4c4f676..9df86b7e 100644 --- a/src/Model/Search/MangaSearch.php +++ b/src/Model/Search/MangaSearch.php @@ -13,7 +13,6 @@ */ class MangaSearch extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Search/MangaSearchListItem.php b/src/Model/Search/MangaSearchListItem.php index 923956bd..dff8df22 100644 --- a/src/Model/Search/MangaSearchListItem.php +++ b/src/Model/Search/MangaSearchListItem.php @@ -12,7 +12,6 @@ */ class MangaSearchListItem { - /** * @var int */ diff --git a/src/Model/Search/PersonSearch.php b/src/Model/Search/PersonSearch.php index 8a67f112..1690b40b 100644 --- a/src/Model/Search/PersonSearch.php +++ b/src/Model/Search/PersonSearch.php @@ -13,7 +13,6 @@ */ class PersonSearch extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Search/PersonSearchListItem.php b/src/Model/Search/PersonSearchListItem.php index fbb6a6b7..764bd770 100644 --- a/src/Model/Search/PersonSearchListItem.php +++ b/src/Model/Search/PersonSearchListItem.php @@ -12,7 +12,6 @@ */ class PersonSearchListItem { - /** * @var int */ diff --git a/src/Model/Search/UserSearch.php b/src/Model/Search/UserSearch.php index 8eb1dee1..8ac027a4 100644 --- a/src/Model/Search/UserSearch.php +++ b/src/Model/Search/UserSearch.php @@ -13,7 +13,6 @@ */ class UserSearch extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/SeasonList/SeasonArchive.php b/src/Model/SeasonList/SeasonArchive.php index 3e6220e6..88abac4b 100644 --- a/src/Model/SeasonList/SeasonArchive.php +++ b/src/Model/SeasonList/SeasonArchive.php @@ -11,7 +11,6 @@ */ class SeasonArchive extends Results { - /** * @param SeasonListParser $parser * @return static diff --git a/src/Model/Seasonal/Seasonal.php b/src/Model/Seasonal/Seasonal.php index e0b492a6..4f5b8dd6 100755 --- a/src/Model/Seasonal/Seasonal.php +++ b/src/Model/Seasonal/Seasonal.php @@ -11,7 +11,6 @@ */ class Seasonal { - /** * @var string|null */ diff --git a/src/Model/Top/TopAnime.php b/src/Model/Top/TopAnime.php index 1156dc47..639125f3 100755 --- a/src/Model/Top/TopAnime.php +++ b/src/Model/Top/TopAnime.php @@ -13,7 +13,6 @@ */ class TopAnime extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Top/TopCharacters.php b/src/Model/Top/TopCharacters.php index 32c81a33..f69f0cd8 100644 --- a/src/Model/Top/TopCharacters.php +++ b/src/Model/Top/TopCharacters.php @@ -13,7 +13,6 @@ */ class TopCharacters extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Top/TopManga.php b/src/Model/Top/TopManga.php index d297f656..ba91388e 100755 --- a/src/Model/Top/TopManga.php +++ b/src/Model/Top/TopManga.php @@ -13,7 +13,6 @@ */ class TopManga extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Top/TopPeople.php b/src/Model/Top/TopPeople.php index f68b041e..64377d0e 100644 --- a/src/Model/Top/TopPeople.php +++ b/src/Model/Top/TopPeople.php @@ -13,7 +13,6 @@ */ class TopPeople extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/User/FavoriteCharacter.php b/src/Model/User/FavoriteCharacter.php index cbdbd72f..8ce5fd0e 100644 --- a/src/Model/User/FavoriteCharacter.php +++ b/src/Model/User/FavoriteCharacter.php @@ -13,7 +13,6 @@ */ class FavoriteCharacter extends CharacterMeta { - /** * @var FavoriteCharacterRelatedEntry */ diff --git a/src/Model/User/Favorites.php b/src/Model/User/Favorites.php index 7969f7c2..ed1c732d 100644 --- a/src/Model/User/Favorites.php +++ b/src/Model/User/Favorites.php @@ -11,7 +11,6 @@ */ class Favorites { - /** * @var array */ diff --git a/src/Model/User/Friends.php b/src/Model/User/Friends.php index 3dc8b420..2dd3e83b 100644 --- a/src/Model/User/Friends.php +++ b/src/Model/User/Friends.php @@ -13,7 +13,6 @@ */ class Friends extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/User/History.php b/src/Model/User/History.php index 8a04b5fd..49aca918 100644 --- a/src/Model/User/History.php +++ b/src/Model/User/History.php @@ -12,7 +12,6 @@ */ class History { - /** * @var MalUrl */ diff --git a/src/Model/User/Profile.php b/src/Model/User/Profile.php index 370c9d73..62d54f29 100644 --- a/src/Model/User/Profile.php +++ b/src/Model/User/Profile.php @@ -13,7 +13,6 @@ */ class Profile { - /** * @var int|null */ diff --git a/src/Model/User/Reviews/UserAnimeReview.php b/src/Model/User/Reviews/UserAnimeReview.php index 49fafc35..dd2b9d99 100644 --- a/src/Model/User/Reviews/UserAnimeReview.php +++ b/src/Model/User/Reviews/UserAnimeReview.php @@ -15,12 +15,10 @@ */ class UserAnimeReview extends AnimeReview { - /** * @var AnimeMeta */ - private $entry; - + private AnimeMeta $entry; /** * @param AnimeReviewParser $parser @@ -35,79 +33,18 @@ public static function fromParser(AnimeReviewParser $parser): UserAnimeReview $instance->malId = $parser->getId(); $instance->url = $parser->getUrl(); $instance->type = $parser->getType(); - $instance->votes = $parser->getHelpfulCount(); + $instance->reactions = $parser->getReactions(); $instance->date = $parser->getDate(); - $instance->scores = $parser->getAnimeScores(); + $instance->score = $parser->getReviewerScore(); $instance->review = $parser->getContent(); + $instance->tags = $parser->getReviewTag(); + $instance->isPreliminary = $parser->isPreliminary(); $instance->episodesWatched = $parser->getEpisodesWatched(); + $instance->isSpoiler = $parser->isSpoiler(); return $instance; } - /** - * @return string - */ - public function getEpisodesWatched(): string - { - return $this->episodesWatched; - } - - /** - * @return AnimeReviewScores - */ - public function getScores(): AnimeReviewScores - { - return $this->scores; - } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } - /** * @return AnimeMeta */ diff --git a/src/Model/User/Reviews/UserMangaReview.php b/src/Model/User/Reviews/UserMangaReview.php index 9ecee36a..ef13d910 100644 --- a/src/Model/User/Reviews/UserMangaReview.php +++ b/src/Model/User/Reviews/UserMangaReview.php @@ -14,12 +14,11 @@ */ class UserMangaReview extends MangaReview { - /** * @var MangaMeta */ - private $entry; - + private MangaMeta $entry; + /** * @param MangaReviewParser $parser * @return UserAnimeReview @@ -33,79 +32,18 @@ public static function fromParser(MangaReviewParser $parser): UserMangaReview $instance->malId = $parser->getId(); $instance->url = $parser->getUrl(); $instance->type = $parser->getType(); - $instance->votes = $parser->getHelpfulCount(); + $instance->reactions = $parser->getReactions(); $instance->date = $parser->getDate(); - $instance->scores = $parser->getMangaScores(); + $instance->score = $parser->getReviewerScore(); $instance->review = $parser->getContent(); + $instance->tags = $parser->getReviewTag(); + $instance->isPreliminary = $parser->isPreliminary(); $instance->chaptersRead = $parser->getChaptersRead(); + $instance->isSpoiler = $parser->isSpoiler(); return $instance; } - /** - * @return string - */ - public function getChaptersRead(): string - { - return $this->chaptersRead; - } - - /** - * @return MangaReviewScores - */ - public function getScores(): MangaReviewScores - { - return $this->scores; - } - - /** - * @return int - */ - public function getMalId(): int - { - return $this->malId; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return int - */ - public function getVotes(): int - { - return $this->votes; - } - - /** - * @return \DateTimeImmutable - */ - public function getDate(): \DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getReview(): string - { - return $this->review; - } - /** * @return MangaMeta */ diff --git a/src/Model/User/Reviews/UserReviews.php b/src/Model/User/Reviews/UserReviews.php index 68197db9..0e785975 100644 --- a/src/Model/User/Reviews/UserReviews.php +++ b/src/Model/User/Reviews/UserReviews.php @@ -13,7 +13,6 @@ */ class UserReviews extends Results implements Pagination { - /** * @var bool */ diff --git a/src/Model/Watch/EpisodeListItem.php b/src/Model/Watch/EpisodeListItem.php index ba8e3df4..7c8e9e93 100644 --- a/src/Model/Watch/EpisodeListItem.php +++ b/src/Model/Watch/EpisodeListItem.php @@ -13,7 +13,6 @@ */ class EpisodeListItem { - /** * @var AnimeMeta */ diff --git a/src/Model/Watch/RecentEpisodeListItem.php b/src/Model/Watch/RecentEpisodeListItem.php index efc76216..6044880e 100644 --- a/src/Model/Watch/RecentEpisodeListItem.php +++ b/src/Model/Watch/RecentEpisodeListItem.php @@ -9,7 +9,6 @@ */ class RecentEpisodeListItem { - /** * @var int */ diff --git a/src/MyAnimeList/MalClient.php b/src/MyAnimeList/MalClient.php index 2edad457..f362deb9 100644 --- a/src/MyAnimeList/MalClient.php +++ b/src/MyAnimeList/MalClient.php @@ -1125,17 +1125,17 @@ public function getMangaGenres(Request\Genre\MangaGenresRequest $request): Model } /** - * @param Request\Reviews\RecentReviewsRequest $request + * @param Request\Reviews\ReviewsRequest $request * * @return * @throws BadResponseException * @throws ParserException */ - public function getRecentReviews(Request\Reviews\RecentReviewsRequest $request): Model\Reviews\RecentReviews + public function getReviews(Request\Reviews\ReviewsRequest $request): Model\Reviews\Reviews { $crawler = $this->ghoutte->request('GET', $request->getPath()); try { - $parser = new Parser\Reviews\RecentReviewsParser($crawler); + $parser = new Parser\Reviews\ReviewsParser($crawler); return $parser->getModel(); } catch (\Exception $e) { diff --git a/src/Parser/Anime/AnimeReviewsParser.php b/src/Parser/Anime/AnimeReviewsParser.php index c0510bff..483344de 100644 --- a/src/Parser/Anime/AnimeReviewsParser.php +++ b/src/Parser/Anime/AnimeReviewsParser.php @@ -53,7 +53,7 @@ public function getCrawler(): Crawler public function getResults(): array { return $this->crawler - ->filterXPath('//div[@class="borderDark"]') + ->filterXPath('//div[contains(@class, "rightside")]//div[contains(@class, "review-element")]') ->each( function (Crawler $c) { return (new AnimeReviewParser($c))->getModel(); diff --git a/src/Parser/Character/AnimeographyParser.php b/src/Parser/Character/AnimeographyParser.php index 94096db8..dcc60bca 100644 --- a/src/Parser/Character/AnimeographyParser.php +++ b/src/Parser/Character/AnimeographyParser.php @@ -13,7 +13,6 @@ */ class AnimeographyParser extends OgraphyParser implements ParserInterface { - /** * @var Crawler */ diff --git a/src/Parser/Club/ClubParser.php b/src/Parser/Club/ClubParser.php index 422a520a..cdb0ab89 100644 --- a/src/Parser/Club/ClubParser.php +++ b/src/Parser/Club/ClubParser.php @@ -18,7 +18,6 @@ */ class ClubParser implements ParserInterface { - /** * @var Crawler */ diff --git a/src/Parser/Club/UserListParser.php b/src/Parser/Club/UserListParser.php index 4c5f3733..679695eb 100644 --- a/src/Parser/Club/UserListParser.php +++ b/src/Parser/Club/UserListParser.php @@ -14,7 +14,6 @@ */ class UserListParser implements ParserInterface { - /** * @var Crawler */ diff --git a/src/Parser/Club/UserProfileParser.php b/src/Parser/Club/UserProfileParser.php index 37224dc6..b862cf26 100644 --- a/src/Parser/Club/UserProfileParser.php +++ b/src/Parser/Club/UserProfileParser.php @@ -15,7 +15,6 @@ */ class UserProfileParser implements ParserInterface { - /** * @var Crawler */ diff --git a/src/Parser/Common/MangaCardParser.php b/src/Parser/Common/MangaCardParser.php index c80ed343..753adec2 100644 --- a/src/Parser/Common/MangaCardParser.php +++ b/src/Parser/Common/MangaCardParser.php @@ -163,7 +163,7 @@ public function getPublishDates(): ?\DateTimeImmutable $node = $this->crawler->filterXPath('//div/div[2]/div/span[contains(@class, "item")][1]'); if ( - !preg_match('~(.*), ([0-9]{1,})~', $node->text(), $matches) + !preg_match('~(.*), ([0-9]{1,})~', $node->text(), $matches) ) { return null; } diff --git a/src/Parser/Manga/MangaReviewsParser.php b/src/Parser/Manga/MangaReviewsParser.php index ac82f608..5474b52f 100644 --- a/src/Parser/Manga/MangaReviewsParser.php +++ b/src/Parser/Manga/MangaReviewsParser.php @@ -42,7 +42,7 @@ public function getModel() : MangaReviews public function getResults(): array { return $this->crawler - ->filterXPath('//div[@class="borderDark"]') + ->filterXPath('//div[contains(@class, "rightside")]//div[contains(@class, "review-element")]') ->each( function (Crawler $c) { return (new MangaReviewParser($c))->getModel(); diff --git a/src/Parser/Recommendations/RecentRecommendationsParser.php b/src/Parser/Recommendations/RecentRecommendationsParser.php index 56d4ca7a..991e6de8 100644 --- a/src/Parser/Recommendations/RecentRecommendationsParser.php +++ b/src/Parser/Recommendations/RecentRecommendationsParser.php @@ -6,7 +6,7 @@ use Jikan\Model\Manga\MangaReview; use Jikan\Model\Recommendations\RecentRecommendations; use Jikan\Model\Recommendations\RecommendationListItem; -use Jikan\Model\Reviews\RecentReviews; +use Jikan\Model\Reviews\Reviews; use Jikan\Parser\Anime\AnimeReviewParser; use Jikan\Parser\Manga\MangaReviewParser; use Symfony\Component\DomCrawler\Crawler; @@ -34,7 +34,7 @@ public function __construct(Crawler $crawler) } /** - * @return RecentReviews + * @return Reviews * @throws \Exception */ public function getModel(): RecentRecommendations diff --git a/src/Parser/Recommendations/UserRecommendationsParser.php b/src/Parser/Recommendations/UserRecommendationsParser.php index 49f7ab14..e4508b60 100644 --- a/src/Parser/Recommendations/UserRecommendationsParser.php +++ b/src/Parser/Recommendations/UserRecommendationsParser.php @@ -7,7 +7,7 @@ use Jikan\Model\Recommendations\RecentRecommendations; use Jikan\Model\Recommendations\RecommendationListItem; use Jikan\Model\Recommendations\UserRecommendations; -use Jikan\Model\Reviews\RecentReviews; +use Jikan\Model\Reviews\Reviews; use Jikan\Parser\Anime\AnimeReviewParser; use Jikan\Parser\Manga\MangaReviewParser; use Symfony\Component\DomCrawler\Crawler; @@ -35,7 +35,7 @@ public function __construct(Crawler $crawler) } /** - * @return RecentReviews + * @return Reviews * @throws \Exception */ public function getModel(): UserRecommendations diff --git a/src/Parser/Reviews/AnimeReviewParser.php b/src/Parser/Reviews/AnimeReviewParser.php index fa68042c..355b7297 100644 --- a/src/Parser/Reviews/AnimeReviewParser.php +++ b/src/Parser/Reviews/AnimeReviewParser.php @@ -7,6 +7,7 @@ use Jikan\Model\Anime\AnimeReview; use Jikan\Model\Anime\AnimeReviewScores; use Jikan\Model\Common\AnimeMeta; +use Jikan\Model\Reviews\Reactions; use Jikan\Model\Reviews\Reviewer; use Jikan\Parser\ParserInterface; use Symfony\Component\DomCrawler\Crawler; @@ -21,7 +22,7 @@ class AnimeReviewParser implements ParserInterface /** * @var Crawler */ - private $crawler; + private Crawler $crawler; /** * AnimeReviewParser constructor. @@ -49,9 +50,9 @@ public function getModel(): AnimeReview public function getAnime() : AnimeMeta { return new AnimeMeta( - $this->getReviewedTitle(), - $this->getReviewedUrl(), - $this->getReviewedImageUrl() + $this->getAnimeTitle(), + $this->getAnimeURL(), + $this->getAnimeImageUrl() ); } @@ -71,7 +72,8 @@ public function getId(): int */ public function getUrl(): string { - $node = $this->crawler->filterXPath('//div[1]/div[3]/div/div/a'); + $node = $this->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "bottom-navi")]/div[@class="open"]/a'); return $node->attr('href'); } @@ -79,10 +81,10 @@ public function getUrl(): string * @return string * @throws \InvalidArgumentException */ - public function getReviewedTitle(): string + public function getAnimeTitle(): string { return $this->crawler - ->filterXPath('//div[1]/div[1]/div[2]/strong/a') + ->filterXPath('//div[1]/div/div[2]/div/a') ->text(); } @@ -90,11 +92,11 @@ public function getReviewedTitle(): string * @return string * @throws \InvalidArgumentException */ - public function getReviewedUrl(): string + public function getAnimeUrl(): string { // User UserReviews page $node = $this->crawler - ->filterXPath('//div[12]/div[1]/div[1]/a'); + ->filterXPath('//div[1]/div/div[2]/div/a'); if ($node->count()) { return $node->attr('href'); @@ -111,11 +113,11 @@ public function getReviewedUrl(): string * @return string * @throws \InvalidArgumentException */ - public function getReviewedImageUrl(): string + public function getAnimeImageUrl(): string { // User UserReviews page $node = $this->crawler - ->filterXPath('//div[12]/div[1]/div[1]/a/img'); + ->filterXPath('//div[1]/div/div[1]/a/img'); if ($node->count()) { return Parser::parseImageQuality($node->attr('data-src')); @@ -134,6 +136,8 @@ public function getReviewedImageUrl(): string */ public function getHelpfulCount(): int { + return 0; //@todo replace with reactions array + // works on Profile pages $node = $this->crawler->filterXPath('//div[1]/div[1]/div[4]/table/tr/td[1]/div/strong/span'); if ($node->count()) { @@ -158,8 +162,9 @@ public function getHelpfulCount(): int */ public function getDate(): \DateTimeImmutable { - $date = $this->crawler->filterXPath('//div[1]/div[1]/div[1]/div[1]')->text(); - $time = $this->crawler->filterXPath('//div[1]/div[1]/div[1]/div[1]')->attr('title'); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "update_at")]'); + $date = $node->text(); + $time = $node->attr('title'); return new \DateTimeImmutable("{$date} {$time}", new \DateTimeZone('UTC')); } @@ -169,18 +174,10 @@ public function getDate(): \DateTimeImmutable */ public function getContent(): string { - // echo htmlentities( - // $this->crawler - // ->filterXPath('//div[contains(@class, "textReadability")]') - // ->html() - // ); - // echo "

"; - // - // return $this->crawler - // ->filterXPath('//div[2]') - // ->text(); - $node = $this->crawler->filterXPath('//div[1]/div[2]'); - $nodeExpanded = $node->filterXPath('//span'); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "text")]'); + $nodeExpanded = $this + ->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "text")]/span[contains(@class, "js-hidden")]'); $node = Parser::removeChildNodes($node); @@ -194,7 +191,6 @@ public function getContent(): string return $content; } - /** * @return Reviewer */ @@ -217,32 +213,48 @@ public function getAnimeScores(): AnimeReviewScores */ public function getType(): ?string { - $node = $this->crawler->filterXPath('//div[1]/div[1]/div[2]/small'); + // Anime/Manga and User Reviews page + $node = $this->crawler->filterXPath('//div/div/div[2]/div[2]/small'); - if (!$node->count()) { - return null; + if ($node->count()) { + return strtolower( + str_replace( + ['(', ')'], + '', + $node->text() + ) + ); } - return strtolower( - str_replace( - ['(', ')'], - '', - $node->text() - ) - ); + // All Reviews Page + $node = $this->crawler->filterXPath('//div/small'); + + if ($node->count()) { + return strtolower( + str_replace( + ['(', ')'], + '', + $node->text() + ) + ); + } + + return null; } /** - * @return int + * @return int|null * @throws \InvalidArgumentException */ - public function getEpisodesWatched(): int + public function getEpisodesWatched(): ?int { - $nodeText = JString::cleanse( - $this->crawler->filterXPath('//div[1]/div[1]/div[1]/div[2]')->text() - ); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div[contains(@class, "preliminary")]/span'); - preg_match('~(\d+) of (.*) episodes seen~', $nodeText, $episodesSeen); + if (!$node->count()) { + return null; + } + + preg_match('~\((\d+)/(.*)\)~', JString::cleanse($node->text()), $episodesSeen); if (empty($episodesSeen)) { return 0; @@ -250,4 +262,64 @@ public function getEpisodesWatched(): int return (int) $episodesSeen[1]; } + + /** + * @return Reactions + */ + public function getReactions(): Reactions + { + return (new ReactionsParser($this->crawler))->getModel(); + } + + /** + * @return int + */ + public function getReviewerScore(): int + { + return (int) $this->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "rating")]/span') + ->text(); + } + + /** + * @return array + */ + public function getReviewTag(): array + { + return $this->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div') + ->each(function (Crawler $crawler) { + return JString::cleanse( + Parser::removeChildNodes($crawler)->text() + ); + }); + } + + /** + * @return bool + */ + public function isPreliminary(): bool + { + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div[contains(@class, "preliminary")]'); + + if ($node->count()) { + return true; + } + + return false; + } + + /** + * @return bool + */ + public function isSpoiler(): bool + { + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div[contains(@class, "spoiler")]'); + + if ($node->count()) { + return true; + } + + return false; + } } diff --git a/src/Parser/Reviews/AnimeReviewScoresParser.php b/src/Parser/Reviews/AnimeReviewScoresParser.php deleted file mode 100644 index 2c990235..00000000 --- a/src/Parser/Reviews/AnimeReviewScoresParser.php +++ /dev/null @@ -1,87 +0,0 @@ -crawler = $crawler; - } - - /** - * @return AnimeReviewScores - * @throws \RuntimeException - * @throws \InvalidArgumentException - */ - public function getModel(): AnimeReviewScores - { - return AnimeReviewScores::fromParser($this); - } - - /** - * @return int - */ - public function getOverallScore() : int - { - return (int) $this->crawler->filterXPath('//table/tr[1]/td[2]/strong')->text(); - } - /** - * @return int - */ - public function getStoryScore() : int - { - return (int) $this->crawler->filterXPath('//table/tr[2]/td[2]')->text(); - } - - /** - * @return int - */ - public function getAnimationScore() : int - { - return (int) $this->crawler->filterXPath('//table/tr[3]/td[2]')->text(); - } - - /** - * @return int - */ - public function getSoundScore() : int - { - return (int) $this->crawler->filterXPath('//table/tr[4]/td[2]')->text(); - } - - /** - * @return int - */ - public function getCharacterScore() : int - { - return (int) $this->crawler->filterXPath('//table/tr[5]/td[2]')->text(); - } - - /** - * @return int - */ - public function getEnjoymentScore() : int - { - return (int) $this->crawler->filterXPath('//table/tr[6]/td[2]')->text(); - } -} diff --git a/src/Parser/Reviews/MangaReviewParser.php b/src/Parser/Reviews/MangaReviewParser.php index 1aea2660..6a070335 100644 --- a/src/Parser/Reviews/MangaReviewParser.php +++ b/src/Parser/Reviews/MangaReviewParser.php @@ -8,6 +8,7 @@ use Jikan\Model\Common\MangaMeta; use Jikan\Model\Manga\MangaReview; use Jikan\Model\Manga\MangaReviewScores; +use Jikan\Model\Reviews\Reactions; use Jikan\Model\Reviews\Reviewer; use Jikan\Parser\Manga\MangaReviewScoresParser; use Jikan\Parser\ParserInterface; @@ -51,9 +52,9 @@ public function getModel(): MangaReview public function getManga() : MangaMeta { return new MangaMeta( - $this->getReviewedTitle(), - $this->getReviewedUrl(), - $this->getReviewedImageUrl() + $this->getMangaTitle(), + $this->getMangaUrl(), + $this->getMangaImageUrl() ); } @@ -73,7 +74,8 @@ public function getId(): int */ public function getUrl(): string { - $node = $this->crawler->filterXPath('//div[1]/div[3]/div/div/a'); + $node = $this->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "bottom-navi")]/div[@class="open"]/a'); return $node->attr('href'); } @@ -107,8 +109,9 @@ public function getHelpfulCount(): int */ public function getDate(): \DateTimeImmutable { - $date = $this->crawler->filterXPath('//div[1]/div[1]/div[1]/div[1]')->text(); - $time = $this->crawler->filterXPath('//div[1]/div[1]/div[1]/div[1]')->attr('title'); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "update_at")]'); + $date = $node->text(); + $time = $node->attr('title'); return new \DateTimeImmutable("{$date} {$time}", new \DateTimeZone('UTC')); } @@ -118,18 +121,10 @@ public function getDate(): \DateTimeImmutable */ public function getContent(): string { - // echo htmlentities( - // $this->crawler - // ->filterXPath('//div[contains(@class, "textReadability")]') - // ->html() - // ); - // echo "

"; - // - // return $this->crawler - // ->filterXPath('//div[2]') - // ->text(); - $node = $this->crawler->filterXPath('//div[1]/div[2]'); - $nodeExpanded = $node->filterXPath('//span'); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "text")]'); + $nodeExpanded = $this + ->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "text")]/span[contains(@class, "js-hidden")]'); $node = Parser::removeChildNodes($node); @@ -165,29 +160,43 @@ public function getMangaScores(): MangaReviewScores */ public function getType(): ?string { - $node = $this->crawler->filterXPath('//div[1]/div[1]/div[2]/small'); + // Anime/Manga and User Reviews page + $node = $this->crawler->filterXPath('//div/div/div[2]/div[2]/small'); - if (!$node->count()) { - return null; + if ($node->count()) { + return strtolower( + str_replace( + ['(', ')'], + '', + $node->text() + ) + ); } - return strtolower( - str_replace( - ['(', ')'], - '', - $node->text() - ) - ); + // All Reviews Page + $node = $this->crawler->filterXPath('//div/small'); + + if ($node->count()) { + return strtolower( + str_replace( + ['(', ')'], + '', + $node->text() + ) + ); + } + + return null; } /** * @return string * @throws \InvalidArgumentException */ - public function getReviewedTitle(): string + public function getMangaTitle(): string { return $this->crawler - ->filterXPath('//div[1]/div[1]/div[2]/strong/a') + ->filterXPath('//div[1]/div/div[2]/div/a') ->text(); } @@ -196,11 +205,11 @@ public function getReviewedTitle(): string * @throws \InvalidArgumentException * @throws \Jikan\Exception\ParserException */ - public function getReviewedImageUrl(): string + public function getMangaImageUrl(): string { // User UserReviews page $node = $this->crawler - ->filterXPath('//div[12]/div[1]/div[1]/a/img'); + ->filterXPath('//div[1]/div/div[1]/a/img'); if ($node->count()) { return Parser::parseImageQuality($node->attr('data-src')); @@ -221,11 +230,11 @@ public function getReviewedImageUrl(): string * @return string * @throws \InvalidArgumentException */ - public function getReviewedUrl(): string + public function getMangaUrl(): string { // User UserReviews page $node = $this->crawler - ->filterXPath('//div[12]/div[1]/div[1]/a'); + ->filterXPath('//div[1]/div/div[2]/div/a'); if ($node->count()) { return $node->attr('href'); @@ -239,21 +248,83 @@ public function getReviewedUrl(): string } /** - * @return int + * @return int|null * @throws \InvalidArgumentException */ - public function getChaptersRead(): int + public function getChaptersRead(): ?int { - $nodeText = JString::cleanse( - $this->crawler->filterXPath('//div[1]/div[1]/div[1]/div[2]')->text() - ); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div[contains(@class, "preliminary")]/span'); + + if (!$node->count()) { + return null; + } - preg_match('~(\d+) of (.*) chapters read~', $nodeText, $chaptersRead); + preg_match('~\((\d+)/(.*)\)~', JString::cleanse($node->text()), $episodesSeen); - if (empty($chaptersRead)) { + if (empty($episodesSeen)) { return 0; } - return (int) $chaptersRead[1]; + return (int) $episodesSeen[1]; + } + + /** + * @return Reactions + */ + public function getReactions(): Reactions + { + return (new ReactionsParser($this->crawler))->getModel(); + } + + /** + * @return int + */ + public function getReviewerScore(): int + { + return (int) $this->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "rating")]/span') + ->text(); + } + + /** + * @return array + */ + public function getReviewTag(): array + { + return $this->crawler + ->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div') + ->each(function (Crawler $crawler) { + return JString::cleanse( + Parser::removeChildNodes($crawler)->text() + ); + }); + } + + /** + * @return bool + */ + public function isPreliminary(): bool + { + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div[contains(@class, "preliminary")]'); + + if ($node->count()) { + return true; + } + + return false; + } + + /** + * @return bool + */ + public function isSpoiler(): bool + { + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "tags")]/div[contains(@class, "spoiler")]'); + + if ($node->count()) { + return true; + } + + return false; } } diff --git a/src/Parser/Reviews/ReactionsParser.php b/src/Parser/Reviews/ReactionsParser.php new file mode 100644 index 00000000..4648ab08 --- /dev/null +++ b/src/Parser/Reviews/ReactionsParser.php @@ -0,0 +1,124 @@ +crawler = $crawler; + $this->reactions = json_decode($this->getReactions(), true); + } + + /** + * @return Reactions + * @throws \RuntimeException + * @throws \InvalidArgumentException + */ + public function getModel(): Reactions + { + return Reactions::fromParser($this); + } + + /** + * @return string + */ + private function getReactions(): string + { + $reactions = JString::cleanse($this->crawler->attr('data-reactions')); + + if (empty($reactions)) { + $reactions = '{"icon":[],"num":0,"count":["0","0","0","0","0","0","0"]}'; + } + + return $reactions; + } + + /** + * @return int + */ + public function getOverall(): int + { + return (int) $this->reactions['num']; + } + + /** + * @return int + */ + public function getNice(): int + { + return (int) $this->reactions['count'][0]; + } + + /** + * @return int + */ + public function getLoveIt(): int + { + return (int) $this->reactions['count'][1]; + } + + /** + * @return int + */ + public function getFunny(): int + { + return (int) $this->reactions['count'][2]; + } + + /** + * @return int + */ + public function getConfusing(): int + { + return (int) $this->reactions['count'][3]; + } + + /** + * @return int + */ + public function getInformative(): int + { + return (int) $this->reactions['count'][4]; + } + + /** + * @return int + */ + public function getWellWritten(): int + { + return (int) $this->reactions['count'][5]; + } + + /** + * @return int + */ + public function getCreative(): int + { + return (int) $this->reactions['count'][6]; + } +} diff --git a/src/Parser/Reviews/ReviewerParser.php b/src/Parser/Reviews/ReviewerParser.php index f7895222..2ed29212 100644 --- a/src/Parser/Reviews/ReviewerParser.php +++ b/src/Parser/Reviews/ReviewerParser.php @@ -46,7 +46,7 @@ public function getModel() public function getUrl(): string { // works on Anime/Manga Review pages - $node = $this->crawler->filterXPath('//div[1]/div[1]/div[2]/table/tr/td[2]/a'); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "username")]/a'); if ($node->count()) { return $node->attr('href'); } @@ -67,7 +67,7 @@ public function getUrl(): string public function getUsername(): string { // works on Anime/Manga Review pages - $node = $this->crawler->filterXPath('//div[1]/div[1]/div[2]/table/tr/td[2]/a'); + $node = $this->crawler->filterXPath('//div/div[2]/div[contains(@class, "username")]/a'); if ($node->count()) { return $node->text(); } @@ -85,7 +85,7 @@ public function getUsername(): string public function getImageUrl(): string { // works on Anime/Manga Review pages - $node = $this->crawler->filterXPath('//div[1]/div[1]/div[2]/table/tr/td[1]/div/a/img'); + $node = $this->crawler->filterXPath('//div/div/a/img'); if ($node->count()) { return Parser::parseImageThumbToHQ( $node->attr('data-src') diff --git a/src/Parser/Reviews/RecentReviewsParser.php b/src/Parser/Reviews/ReviewsParser.php similarity index 53% rename from src/Parser/Reviews/RecentReviewsParser.php rename to src/Parser/Reviews/ReviewsParser.php index d3fab705..b3217dfd 100644 --- a/src/Parser/Reviews/RecentReviewsParser.php +++ b/src/Parser/Reviews/ReviewsParser.php @@ -2,9 +2,9 @@ namespace Jikan\Parser\Reviews; -use Jikan\Model\Reviews\Recent\RecentAnimeReview; -use Jikan\Model\Reviews\Recent\RecentMangaReview; -use Jikan\Model\Reviews\RecentReviews; +use Jikan\Model\Reviews\FullAnimeReview; +use Jikan\Model\Reviews\FullMangaReview; +use Jikan\Model\Reviews\Reviews; use Symfony\Component\DomCrawler\Crawler; /** @@ -12,13 +12,12 @@ * * @package Jikan\Parser\Top */ -class RecentReviewsParser +class ReviewsParser { /** * @var Crawler */ - private $crawler; - + private Crawler $crawler; /** * CharacterListItemParser constructor. @@ -31,12 +30,12 @@ public function __construct(Crawler $crawler) } /** - * @return RecentReviews + * @return Reviews * @throws \Exception */ - public function getModel(): RecentReviews + public function getModel(): Reviews { - return RecentReviews::fromParser($this); + return Reviews::fromParser($this); } /** @@ -44,24 +43,21 @@ public function getModel(): RecentReviews * @throws \RuntimeException * @throws \InvalidArgumentException|\Exception */ - public function getRecentReviews(): array + public function getReviews(): array { return array_filter( $this->crawler - ->filterXPath('//*[@id="content"]/div[@class="borderDark"]') + ->filterXPath('//*[@id="content"]//div[contains(@class, "review-element")]') ->each( function (Crawler $crawler) { - // If requested by $type `Constants::TOP_REVIEWS_BEST_VOTED`; both types can be returned - // So we check types here to allow the ability to parse and return both - // Anime Review - if ($crawler->filterXPath('//div[1]/div[1]/div[2]/small')->text() === '(Anime)') { - return RecentAnimeReview::fromParser(new AnimeReviewParser($crawler)); + if ($crawler->filterXPath('//div/small')->text() === '(Anime)') { + return FullAnimeReview::fromParser(new AnimeReviewParser($crawler)); } // Manga Review - if ($crawler->filterXPath('//div[1]/div[1]/div[2]/small')->text() === '(Manga)') { - return RecentMangaReview::fromParser(new MangaReviewParser($crawler)); + if ($crawler->filterXPath('//div/small')->text() === '(Manga)') { + return FullMangaReview::fromParser(new MangaReviewParser($crawler)); } return null; diff --git a/src/Parser/User/Reviews/UserReviewsParser.php b/src/Parser/User/Reviews/UserReviewsParser.php index 5bae12f1..09655a97 100644 --- a/src/Parser/User/Reviews/UserReviewsParser.php +++ b/src/Parser/User/Reviews/UserReviewsParser.php @@ -17,7 +17,7 @@ class UserReviewsParser /** * @var Crawler */ - private $crawler; + private Crawler $crawler; /** * UsernameByIdParser constructor. @@ -36,26 +36,24 @@ public function getModel(): Model\User\Reviews\UserReviews public function getReviews() : array { - $node = $this->crawler->filterXPath('//*[@id="content"]/table/tr/td[2]/div[@class="borderDark"]'); + $node = $this->crawler->filterXPath('//*[@id="content"]/table/tr/td[2]//div[contains(@class, "review-element")]'); if (!$node->count()) { return []; } return $node->each(function (Crawler $crawler) { - // Anime Review - if ($crawler->filterXPath('//div[2]/div[2]/small[1]')->text() === '(Anime)') { + if ($crawler->filterXPath('//div/div/div[2]/div[2]/small')->text() === '(Anime)') { return Model\User\Reviews\UserAnimeReview::fromParser(new AnimeReviewParser($crawler)); } // Manga Review - if ($crawler->filterXPath('//div[2]/div[2]/small[1]')->text() === '(Manga)') { + if ($crawler->filterXPath('//div/div/div[2]/div[2]/small')->text() === '(Manga)') { return Model\User\Reviews\UserMangaReview::fromParser(new MangaReviewParser($crawler)); } }); } - public function hasNextPage() : bool { // TODO: Add implementation diff --git a/src/Request/Anime/AnimeReviewsRequest.php b/src/Request/Anime/AnimeReviewsRequest.php index 3035b80f..fa22e4ac 100644 --- a/src/Request/Anime/AnimeReviewsRequest.php +++ b/src/Request/Anime/AnimeReviewsRequest.php @@ -2,6 +2,7 @@ namespace Jikan\Request\Anime; +use Jikan\Helper\Constants; use Jikan\Request\RequestInterface; /** @@ -14,12 +15,27 @@ class AnimeReviewsRequest implements RequestInterface /** * @var int */ - private $id; + private int $id; /** * @var int */ - private $page; + private int $page; + + /** + * @var string + */ + private string $sort; + + /** + * @var bool + */ + private bool $spoilers; + + /** + * @var bool + */ + private bool $preliminary; /** * AnimeReviewsRequest constructor. @@ -27,10 +43,13 @@ class AnimeReviewsRequest implements RequestInterface * @param int $id * @param int $page */ - public function __construct(int $id, int $page = 1) + public function __construct(int $id, int $page = 1, string $sort = Constants::REVIEWS_SORT_MOST_VOTED, bool $spoilers = true, bool $preliminary = true) { $this->id = $id; $this->page = $page; + $this->sort = $sort; + $this->spoilers = $spoilers; + $this->preliminary = $preliminary; } /** @@ -38,7 +57,16 @@ public function __construct(int $id, int $page = 1) */ public function getPath(): string { - return sprintf('https://myanimelist.net/anime/%d/jikan/reviews?p=%d', $this->id, $this->page); + $query = '?'.http_build_query( + [ + 'spoiler' => $this->spoilers ? 'on' : 'off', + 'preliminary' => $this->preliminary ? 'on' : 'off', + 'sort' => $this->sort, + 'p' => $this->page + ] + ); + + return sprintf('https://myanimelist.net/anime/%d/jikan/reviews%s', $this->id, $query); } /** @@ -56,4 +84,28 @@ public function getPage(): int { return $this->page; } + + /** + * @return string + */ + public function getSort(): string + { + return $this->sort; + } + + /** + * @return bool + */ + public function isSpoilers(): bool + { + return $this->spoilers; + } + + /** + * @return bool + */ + public function isPreliminary(): bool + { + return $this->preliminary; + } } diff --git a/src/Request/Club/ClubRequest.php b/src/Request/Club/ClubRequest.php index 20451b5b..e2929e39 100644 --- a/src/Request/Club/ClubRequest.php +++ b/src/Request/Club/ClubRequest.php @@ -11,7 +11,6 @@ */ class ClubRequest implements RequestInterface { - /** * @var int */ diff --git a/src/Request/Club/UserListRequest.php b/src/Request/Club/UserListRequest.php index 4fec66c0..0faa683f 100644 --- a/src/Request/Club/UserListRequest.php +++ b/src/Request/Club/UserListRequest.php @@ -11,7 +11,6 @@ */ class UserListRequest implements RequestInterface { - /** * @var int */ diff --git a/src/Request/Manga/MangaRequest.php b/src/Request/Manga/MangaRequest.php index e5bac3de..af760d6d 100644 --- a/src/Request/Manga/MangaRequest.php +++ b/src/Request/Manga/MangaRequest.php @@ -11,7 +11,6 @@ */ class MangaRequest implements RequestInterface { - /** * @var int */ diff --git a/src/Request/Manga/MangaReviewsRequest.php b/src/Request/Manga/MangaReviewsRequest.php index 16a5bdf3..bf08c0d0 100644 --- a/src/Request/Manga/MangaReviewsRequest.php +++ b/src/Request/Manga/MangaReviewsRequest.php @@ -2,6 +2,7 @@ namespace Jikan\Request\Manga; +use Jikan\Helper\Constants; use Jikan\Request\RequestInterface; /** @@ -14,12 +15,27 @@ class MangaReviewsRequest implements RequestInterface /** * @var int */ - private $id; + private int $id; /** * @var int */ - private $page; + private int $page; + + /** + * @var string + */ + private string $sort; + + /** + * @var bool + */ + private bool $spoilers; + + /** + * @var bool + */ + private bool $preliminary; /** * MangaReviewsRequest constructor. @@ -27,10 +43,13 @@ class MangaReviewsRequest implements RequestInterface * @param int $id * @param int $page */ - public function __construct(int $id, int $page = 1) + public function __construct(int $id, int $page = 1, string $sort = Constants::REVIEWS_SORT_MOST_VOTED, bool $spoilers = true, bool $preliminary = true) { $this->id = $id; $this->page = $page; + $this->sort = $sort; + $this->spoilers = $spoilers; + $this->preliminary = $preliminary; } /** @@ -38,7 +57,16 @@ public function __construct(int $id, int $page = 1) */ public function getPath(): string { - return sprintf('https://myanimelist.net/manga/%d/jikan/reviews?p=%d', $this->id, $this->page); + $query = '?'.http_build_query( + [ + 'spoiler' => $this->spoilers ? 'on' : 'off', + 'preliminary' => $this->preliminary ? 'on' : 'off', + 'sort' => $this->sort, + 'p' => $this->page + ] + ); + + return sprintf('https://myanimelist.net/manga/%d/jikan/reviews%s', $this->id, $query); } /** @@ -56,4 +84,28 @@ public function getPage(): int { return $this->page; } + + /** + * @return string + */ + public function getSort(): string + { + return $this->sort; + } + + /** + * @return bool + */ + public function isSpoilers(): bool + { + return $this->spoilers; + } + + /** + * @return bool + */ + public function isPreliminary(): bool + { + return $this->preliminary; + } } diff --git a/src/Request/Reviews/RecentReviewsRequest.php b/src/Request/Reviews/RecentReviewsRequest.php deleted file mode 100644 index 30174e59..00000000 --- a/src/Request/Reviews/RecentReviewsRequest.php +++ /dev/null @@ -1,94 +0,0 @@ -page = $page; - - if (null !== $type) { - if (!\in_array( - $type, - [ - Constants::RECENT_REVIEW_BEST_VOTED, - Constants::RECENT_REVIEW_ANIME, - Constants::RECENT_REVIEW_MANGA, - ], - true - ) - ) { - throw new \InvalidArgumentException(sprintf('Review type %s is not valid', $type)); - } - - $this->type = $type; - } - } - - /** - * Get the path to request - * - * @return string - */ - public function getPath(): string - { - if ($this->type === Constants::RECENT_REVIEW_BEST_VOTED) { - return 'https://myanimelist.net/reviews.php?'.http_build_query( - [ - 'p' => $this->page, - 'st' => $this->type, - ] - ); - } - - return 'https://myanimelist.net/reviews.php?'.http_build_query( - [ - 'p' => $this->page, - 't' => $this->type, - ] - ); - } - - /** - * @return int - */ - public function getPage(): int - { - return $this->page; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } -} diff --git a/src/Request/Reviews/ReviewsRequest.php b/src/Request/Reviews/ReviewsRequest.php new file mode 100644 index 00000000..fa2b8567 --- /dev/null +++ b/src/Request/Reviews/ReviewsRequest.php @@ -0,0 +1,82 @@ +page = $page; + $this->sort = $sort; + $this->spoilers = $spoilers; + $this->preliminary = $preliminary; + + if (null !== $type) { + if (!\in_array( + $type, + [ + Constants::ANIME, + Constants::MANGA, + ], + true + ) + ) { + throw new \InvalidArgumentException(sprintf('Review type %s is not valid', $type)); + } + + $this->type = $type; + } + } + + /** + * Get the path to request + * + * @return string + */ + public function getPath(): string + { + return 'https://myanimelist.net/reviews.php?'.http_build_query( + [ + 'p' => $this->page, + 't' => $this->type, + 'spoiler' => $this->spoilers ? 'on' : 'off', + 'preliminary' => $this->preliminary ? 'on' : 'off', + 'sort' => $this->sort, + ] + ); + } +} diff --git a/src/Request/Search/AnimeSearchRequest.php b/src/Request/Search/AnimeSearchRequest.php index 16ab4956..9132ea71 100644 --- a/src/Request/Search/AnimeSearchRequest.php +++ b/src/Request/Search/AnimeSearchRequest.php @@ -12,7 +12,6 @@ */ class AnimeSearchRequest implements RequestInterface { - /** * @var string|null */ diff --git a/src/Request/Search/CharacterSearchRequest.php b/src/Request/Search/CharacterSearchRequest.php index 6e8d022a..ed775ca8 100644 --- a/src/Request/Search/CharacterSearchRequest.php +++ b/src/Request/Search/CharacterSearchRequest.php @@ -12,7 +12,6 @@ */ class CharacterSearchRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/Search/MangaSearchRequest.php b/src/Request/Search/MangaSearchRequest.php index 6587608a..bbc31f1a 100644 --- a/src/Request/Search/MangaSearchRequest.php +++ b/src/Request/Search/MangaSearchRequest.php @@ -12,7 +12,6 @@ */ class MangaSearchRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/Search/PersonSearchRequest.php b/src/Request/Search/PersonSearchRequest.php index e4713029..71a731f7 100644 --- a/src/Request/Search/PersonSearchRequest.php +++ b/src/Request/Search/PersonSearchRequest.php @@ -12,7 +12,6 @@ */ class PersonSearchRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/Search/UserSearchRequest.php b/src/Request/Search/UserSearchRequest.php index 680053fb..0c0aee46 100644 --- a/src/Request/Search/UserSearchRequest.php +++ b/src/Request/Search/UserSearchRequest.php @@ -13,7 +13,6 @@ */ class UserSearchRequest implements RequestInterface { - /** * @var string|null */ diff --git a/src/Request/User/RecentlyOnlineUsersRequest.php b/src/Request/User/RecentlyOnlineUsersRequest.php index 65d90564..4653e4e4 100644 --- a/src/Request/User/RecentlyOnlineUsersRequest.php +++ b/src/Request/User/RecentlyOnlineUsersRequest.php @@ -11,7 +11,6 @@ */ class RecentlyOnlineUsersRequest implements RequestInterface { - /** * @return string */ diff --git a/src/Request/User/UserAnimeListRequest.php b/src/Request/User/UserAnimeListRequest.php index a75746c3..7481c5c8 100644 --- a/src/Request/User/UserAnimeListRequest.php +++ b/src/Request/User/UserAnimeListRequest.php @@ -12,7 +12,6 @@ */ class UserAnimeListRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UserClubsRequest.php b/src/Request/User/UserClubsRequest.php index ff125ac1..a30c6c48 100644 --- a/src/Request/User/UserClubsRequest.php +++ b/src/Request/User/UserClubsRequest.php @@ -11,7 +11,6 @@ */ class UserClubsRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UserFriendsRequest.php b/src/Request/User/UserFriendsRequest.php index 8aa28828..2245a82a 100644 --- a/src/Request/User/UserFriendsRequest.php +++ b/src/Request/User/UserFriendsRequest.php @@ -11,7 +11,6 @@ */ class UserFriendsRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UserHistoryRequest.php b/src/Request/User/UserHistoryRequest.php index 1bb63b34..eb9899c1 100644 --- a/src/Request/User/UserHistoryRequest.php +++ b/src/Request/User/UserHistoryRequest.php @@ -11,7 +11,6 @@ */ class UserHistoryRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UserMangaListRequest.php b/src/Request/User/UserMangaListRequest.php index 48e3b6d8..317b6c8f 100644 --- a/src/Request/User/UserMangaListRequest.php +++ b/src/Request/User/UserMangaListRequest.php @@ -12,7 +12,6 @@ */ class UserMangaListRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UserProfileRequest.php b/src/Request/User/UserProfileRequest.php index 29b45560..55ec5001 100644 --- a/src/Request/User/UserProfileRequest.php +++ b/src/Request/User/UserProfileRequest.php @@ -11,7 +11,6 @@ */ class UserProfileRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UserRecommendationsRequest.php b/src/Request/User/UserRecommendationsRequest.php index 37e0f4fc..61d583ab 100644 --- a/src/Request/User/UserRecommendationsRequest.php +++ b/src/Request/User/UserRecommendationsRequest.php @@ -11,7 +11,6 @@ */ class UserRecommendationsRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UserReviewsRequest.php b/src/Request/User/UserReviewsRequest.php index a4cf4ce2..d5619cef 100644 --- a/src/Request/User/UserReviewsRequest.php +++ b/src/Request/User/UserReviewsRequest.php @@ -11,7 +11,6 @@ */ class UserReviewsRequest implements RequestInterface { - /** * @var string */ diff --git a/src/Request/User/UsernameByIdRequest.php b/src/Request/User/UsernameByIdRequest.php index 30992be5..7e2da2b0 100644 --- a/src/Request/User/UsernameByIdRequest.php +++ b/src/Request/User/UsernameByIdRequest.php @@ -11,7 +11,6 @@ */ class UsernameByIdRequest implements RequestInterface { - /** * @var int */ diff --git a/src/Request/Watch/PopularEpisodesRequest.php b/src/Request/Watch/PopularEpisodesRequest.php index efec2449..314d9e2e 100644 --- a/src/Request/Watch/PopularEpisodesRequest.php +++ b/src/Request/Watch/PopularEpisodesRequest.php @@ -11,7 +11,6 @@ */ class PopularEpisodesRequest implements RequestInterface { - /** * @return string */ diff --git a/src/Request/Watch/PopularPromotionalVideosRequest.php b/src/Request/Watch/PopularPromotionalVideosRequest.php index b20fd9d6..bd14694d 100644 --- a/src/Request/Watch/PopularPromotionalVideosRequest.php +++ b/src/Request/Watch/PopularPromotionalVideosRequest.php @@ -11,7 +11,6 @@ */ class PopularPromotionalVideosRequest implements RequestInterface { - /** * @return string */ diff --git a/src/Request/Watch/RecentEpisodesRequest.php b/src/Request/Watch/RecentEpisodesRequest.php index 1951dd14..1bc996a2 100644 --- a/src/Request/Watch/RecentEpisodesRequest.php +++ b/src/Request/Watch/RecentEpisodesRequest.php @@ -11,7 +11,6 @@ */ class RecentEpisodesRequest implements RequestInterface { - /** * @return string */ diff --git a/src/Request/Watch/RecentPromotionalVideosRequest.php b/src/Request/Watch/RecentPromotionalVideosRequest.php index 3df0935b..e7c562f0 100644 --- a/src/Request/Watch/RecentPromotionalVideosRequest.php +++ b/src/Request/Watch/RecentPromotionalVideosRequest.php @@ -11,7 +11,6 @@ */ class RecentPromotionalVideosRequest implements RequestInterface { - /** * @var int */ diff --git a/test/JikanTest/HttpFilesystemCacheClientCallback.php b/test/JikanTest/HttpFilesystemCacheClientCallback.php index 83e466bf..14a9d2a3 100644 --- a/test/JikanTest/HttpFilesystemCacheClientCallback.php +++ b/test/JikanTest/HttpFilesystemCacheClientCallback.php @@ -7,12 +7,26 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; +/** + * + */ class HttpFilesystemCacheClientCallback { - private $cachePath; - private $httpClient; + /** + * @var string + */ + private string $cachePath; - public function __construct($cachePath, HttpClientInterface $httpClient = null) + /** + * @var HttpClientInterface + */ + private HttpClientInterface $httpClient; + + /** + * @param string $cachePath + * @param HttpClientInterface|null $httpClient + */ + public function __construct(string $cachePath, HttpClientInterface $httpClient = null) { $this->httpClient = $httpClient ?? HttpClient::create(); if (!is_dir($cachePath)) { @@ -23,6 +37,16 @@ public function __construct($cachePath, HttpClientInterface $httpClient = null) $this->cachePath = $cachePath; } + /** + * @param string $method + * @param string $url + * @param array $options + * @return ResponseInterface + * @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface + * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface + * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface + * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface + */ public function __invoke(string $method, string $url, array $options = []): ResponseInterface { $hash = sha1(json_encode(compact('method', 'url', 'options'))); @@ -35,4 +59,4 @@ public function __invoke(string $method, string $url, array $options = []): Resp $data = file_get_contents($filePath); return new MockResponse($data); } -} \ No newline at end of file +} diff --git a/test/JikanTest/JikanTest.php b/test/JikanTest/JikanTest.php deleted file mode 100644 index 0f3e9965..00000000 --- a/test/JikanTest/JikanTest.php +++ /dev/null @@ -1,442 +0,0 @@ -jikan = new MalClient($this->httpClient); - } - - /** - * @test - */ - public function it_gets_anime() - { - $anime = $this->jikan->getAnime(new \Jikan\Request\Anime\AnimeRequest(21)); - self::assertInstanceOf(\Jikan\Model\Anime\Anime::class, $anime); - } - - /** - * @test - */ - public function it_gets_unapproved_anime() - { - $anime = $this->jikan->getAnime(new \Jikan\Request\Anime\AnimeRequest(48104)); - self::assertEquals(false, $anime->isApproved()); - } - - /** - * @test - */ - public function it_gets_manga() - { - $manga = $this->jikan->getManga(new \Jikan\Request\Manga\MangaRequest(11)); - self::assertInstanceOf(\Jikan\Model\Manga\Manga::class, $manga); - } - - /** - * @test - */ - public function it_gets_unapproved_manga() - { - $manga = $this->jikan->getManga(new \Jikan\Request\Manga\MangaRequest(145036)); - self::assertEquals(false, $manga->isApproved()); - } - - /** - * @test - */ - public function it_gets_characters() - { - $character = $this->jikan->getCharacter(new \Jikan\Request\Character\CharacterRequest(116281)); - self::assertInstanceOf(\Jikan\Model\Character\Character::class, $character); - self::assertCount(14, $character->getAnimeography()); - self::assertCount(2, $character->getMangaography()); - self::assertCount(7, $character->getVoiceActors()); - } - - /** - * @test - */ - public function it_gets_person() - { - $person = $this->jikan->getPerson(new \Jikan\Request\Person\PersonRequest(1)); - self::assertInstanceOf(\Jikan\Model\Person\Person::class, $person); - self::assertCount(420, $person->getVoiceActingRoles()); - self::assertCount(15, $person->getAnimeStaffPositions()); - self::assertCount(0, $person->getPublishedManga()); - } - - /** - * @test - */ - public function it_gets_seasonal_anime() - { - $seasonal = $this->jikan->getSeasonal(new \Jikan\Request\Seasonal\SeasonalRequest(2018, 'spring')); - self::assertInstanceOf(\Jikan\Model\Seasonal\Seasonal::class, $seasonal); - self::assertCount(279, $seasonal->getAnime()); - self::assertContainsOnlyInstancesOf(\Jikan\Model\Seasonal\SeasonalAnime::class, $seasonal->getAnime()); - } - - /** - * @test - */ - public function it_gets_user_profile() - { - $user = $this->jikan->getUserProfile(new \Jikan\Request\User\UserProfileRequest('sandshark')); - self::assertInstanceOf(\Jikan\Model\User\Profile::class, $user); - self::assertInstanceOf(\Jikan\Model\User\AnimeStats::class, $user->getAnimeStats()); - self::assertInstanceOf(\Jikan\Model\User\MangaStats::class, $user->getMangaStats()); - } - - /** - * @test - */ - public function it_gets_schedule() - { - $schedule = $this->jikan->getSchedule(new \Jikan\Request\Schedule\ScheduleRequest()); - self::assertInstanceOf(\Jikan\Model\Schedule\Schedule::class, $schedule); - } - - /** - * @test - */ - public function it_gets_friends() - { - $friends = $this->jikan->getUserFriends(new \Jikan\Request\User\UserFriendsRequest('morshuwarrior')); - self::assertContainsOnlyInstancesOf(Friend::class, $friends->getResults()); - self::assertCount(100, $friends->getResults()); - $usernames = array_map(function ($item) { - return $item->getUser()->getUsername(); - }, $friends->getResults()); - self::assertContains('mutouyusei18', $usernames); - self::assertContains('king_t_challa', $usernames); - self::assertContains('johnyjohny', $usernames); - - // Second page - $friends = $this->jikan->getUserFriends(new \Jikan\Request\User\UserFriendsRequest('morshuwarrior', 2)); - self::assertContainsOnlyInstancesOf(Friend::class, $friends->getResults()); - self::assertCount(100, $friends->getResults()); - $usernames = array_map(function ($item) { - return $item->getUser()->getUsername(); - }, $friends->getResults()); - self::assertNotContains('mutouyusei18', $usernames); - self::assertNotContains('king_t_challa', $usernames); - self::assertNotContains('johnyjohny', $usernames); - self::assertContains('MizzyMizuki', $usernames); - - // Empty page - $friends = $this->jikan->getUserFriends(new \Jikan\Request\User\UserFriendsRequest('morshuwarrior', 100)); - self::assertCount(0, $friends->getResults()); - } - - /** - * @test - */ - public function it_gets_producer() - { - $producer = $this->jikan->getProducer(new \Jikan\Request\Producer\ProducerRequest(1)); - self::assertInstanceOf(\Jikan\Model\Producer\Producer::class, $producer); - } - - /** - * @test - */ - public function it_gets_characters_and_staff() - { - $charactersAndStaff = $this->jikan->getAnimeCharactersAndStaff( - new \Jikan\Request\Anime\AnimeCharactersAndStaffRequest(35073) - ); - $staff = $charactersAndStaff->getStaff(); - $characters = $charactersAndStaff->getCharacters(); - self::assertCount(56, $characters); - self::assertCount(26, $staff); - } - - /** - * @test - */ - public function it_gets_anime_videos() - { - $videos = $this->jikan->getAnimeVideos(new \Jikan\Request\Anime\AnimeVideosRequest(1)); - $promos = $videos->getPromos(); - $episodes = $videos->getEpisodes(); - self::assertCount(3, $promos); - self::assertCount(26, $episodes); - } - - /** - * @test - */ - public function it_gets_anime_pictures() - { - $pictures = $this->jikan->getAnimePictures(new \Jikan\Request\Anime\AnimePicturesRequest(1)); - self::assertCount(13, $pictures); - } - - /** - * @test - */ - public function it_gets_manga_pictures() - { - $pictures = $this->jikan->getMangaPictures(new \Jikan\Request\Manga\MangaPicturesRequest(1)); - self::assertCount(7, $pictures); - } - - /** - * @test - */ - public function it_gets_person_pictures() - { - $pictures = $this->jikan->getPersonPictures(new \Jikan\Request\Person\PersonPicturesRequest(1)); - self::assertCount(7, $pictures); - } - - /** - * @test - */ - public function it_gets_character_pictures() - { - $pictures = $this->jikan->getCharacterPictures(new \Jikan\Request\Character\CharacterPicturesRequest(1)); - self::assertCount(15, $pictures); - } - - /** - * @test - */ - public function it_gets_manga_news() - { - $items = $this->jikan->getNewsList(new MangaNewsRequest(2))->getResults(); - self::assertCount(25, $items); - self::assertContainsOnlyInstancesOf(NewsListItem::class, $items); - } - - /** - * @test - */ - public function it_gets_anime_news() - { - $items = $this->jikan->getNewsList(new AnimeNewsRequest(21))->getResults(); - self::assertCount(30, $items); - self::assertContainsOnlyInstancesOf(NewsListItem::class, $items); - } - - /** - * @test - */ - public function it_gets_anime_search() - { - $search = $this->jikan->getAnimeSearch(new \Jikan\Request\Search\AnimeSearchRequest('Fate')); - self::assertCount(50, $search->getResults()); - self::assertContainsOnlyInstancesOf(\Jikan\Model\Search\AnimeSearchListItem::class, $search->getResults()); - self::assertEquals(20, $search->getLastVisiblePage()); - } - - /** - * @test - */ - public function it_gets_manga_search() - { - $search = $this->jikan->getMangaSearch(new \Jikan\Request\Search\MangaSearchRequest('Fate')); - self::assertCount(50, $search->getResults()); - self::assertContainsOnlyInstancesOf(\Jikan\Model\Search\MangaSearchListItem::class, $search->getResults()); - self::assertEquals(20, $search->getLastVisiblePage()); - } - - /** - * @test - */ - public function it_gets_character_search() - { - $search = $this->jikan->getCharacterSearch(new \Jikan\Request\Search\CharacterSearchRequest('Fate')); - self::assertCount(50, $search->getResults()); - self::assertContainsOnlyInstancesOf(\Jikan\Model\Search\CharacterSearchListItem::class, $search->getResults()); - self::assertEquals(14, $search->getLastVisiblePage()); - } - - /** - * @test - */ - public function it_gets_person_search() - { - $search = $this->jikan->getPersonSearch(new \Jikan\Request\Search\PersonSearchRequest('Ara')); - self::assertCount(50, $search->getResults()); - self::assertContainsOnlyInstancesOf(\Jikan\Model\Search\PersonSearchListItem::class, $search->getResults()); - self::assertEquals(20, $search->getLastVisiblePage()); - } - - /** - * @test - */ - public function it_gets_manga_characters() - { - $characters = $this->jikan->getMangaCharacters(new \Jikan\Request\Manga\MangaCharactersRequest(2)); - self::assertCount(74, $characters); - self::assertContainsOnlyInstancesOf(\Jikan\Model\Manga\CharacterListItem::class, $characters); - } - - /** - * @test - */ - public function it_gets_top_anime() - { - $anime = $this->jikan->getTopAnime(new \Jikan\Request\Top\TopAnimeRequest()); - self::assertCount(50, $anime->getResults()); - self::assertContainsOnlyInstancesOf(TopAnimeListItem::class, $anime->getResults()); - $titles = array_map(function ($item) { - return $item->getTitle(); - }, $anime->getResults()); - self::assertContains('Fullmetal Alchemist: Brotherhood', $titles); - self::assertContains('Steins;Gate', $titles); - } - - /** - * @test - */ - public function it_gets_top_manga() - { - $manga = $this->jikan->getTopManga(new \Jikan\Request\Top\TopMangaRequest()); - self::assertCount(50, $manga->getResults()); - self::assertContainsOnlyInstancesOf(TopMangaListItem::class, $manga->getResults()); - $titles = array_map(function ($item) { - return $item->getTitle(); - }, $manga->getResults()); - self::assertContains('Berserk', $titles); - self::assertContains('One Piece', $titles); - } - - /** - * @test - */ - public function it_gets_top_characters() - { - $characters = $this->jikan->getTopCharacters(new \Jikan\Request\Top\TopCharactersRequest()); - self::assertCount(50, $characters->getResults()); - self::assertContainsOnlyInstancesOf(TopCharacterListItem::class, $characters->getResults()); - $titles = array_map(function ($item) { - return $item->getTitle(); - }, $characters->getResults()); - self::assertContains('Lamperouge, Lelouch', $titles); - self::assertContains('Monkey D., Luffy', $titles); - } - - /** - * @test - */ - public function it_gets_top_people() - { - $people = $this->jikan->getTopPeople(new \Jikan\Request\Top\TopPeopleRequest()); - self::assertCount(50, $people->getResults()); - self::assertContainsOnlyInstancesOf(TopPersonListItem::class, $people->getResults()); - $titles = array_map(function ($item) { - return $item->getTitle(); - }, $people->getResults()); - self::assertContains('Hanazawa, Kana', $titles); - self::assertContains('Asano, Inio', $titles); - } - - /** - * @test - */ - public function it_gets_anime_forum() - { - $topics = $this->jikan->getAnimeForum(new AnimeForumRequest(21)); - self::assertCount(15, $topics); - self::assertContainsOnlyInstancesOf(ForumTopic::class, $topics); - $titles = array_map(function ($item) { - return $item->getTitle(); - }, $topics); - self::assertContains('My Top 5 Arcs, What Are Yours?', $titles); - self::assertContains('One Piece Episode 28 Discussion', $titles); - } - - /** - * @test - */ - public function it_gets_manga_forum() - { - $topics = $this->jikan->getMangaForum(new MangaForumRequest(21)); - self::assertCount(15, $topics); - self::assertContainsOnlyInstancesOf(ForumTopic::class, $topics); - $titles = array_map(function ($item) { - return $item->getTitle(); - }, $topics); - self::assertContains('Death Note Chapter 54 Discussion', $titles); - self::assertContains('Death Note Chapter 91 Discussion', $titles); - } - - /** - * @test - */ - public function it_gets_user_history() - { - $history = $this->jikan->getUserHistory(new \Jikan\Request\User\UserHistoryRequest('morshuwarrior')); - self::assertCount(82, $history); - self::assertContainsOnlyInstancesOf(\Jikan\Model\User\History::class, $history); - } - - /** - * @test - */ - public function it_gets_anime_episodes() - { - $episodes = $this->jikan->getAnimeEpisodes(new \Jikan\Request\Anime\AnimeEpisodesRequest(21)); - self::assertCount(100, $episodes->getResults()); - self::assertEquals(11, $episodes->getLastVisiblePage()); - self::assertContainsOnlyInstancesOf(\Jikan\Model\Anime\EpisodeListItem::class, $episodes->getResults()); - } - - /** - * @test - */ - public function it_gets_user_anime_list() // TODO: Add more test cases - { - $expectedStartDate = new DateTimeImmutable('2017-10-14'); - $expectedUserStartDate = new DateTimeImmutable('2017-10-14'); - $expectedEndDate = new DateTimeImmutable('2018-03-31'); - $expectedUserEndDate = new DateTimeImmutable('2018-03-31'); - - $animeList = $this->jikan->getUserAnimeList( - new \Jikan\Request\User\UserAnimeListRequest('ivanovishado', 1, Constants::USER_ANIME_LIST_COMPLETED) - ); - - foreach ($animeList as $anime) { - $title = $anime->getTitle(); - if ($title === '3-gatsu no Lion 2nd Season') { - self::assertEquals($expectedStartDate, $anime->getStartDate()); - self::assertEquals($expectedUserStartDate, $anime->getWatchStartDate()); - self::assertEquals($expectedEndDate, $anime->getEndDate()); - self::assertEquals($expectedUserEndDate, $anime->getWatchEndDate()); - return; - } - } - } -} diff --git a/test/JikanTest/Model/AnimeTest.php b/test/JikanTest/Model/AnimeTest.php deleted file mode 100644 index 9479472e..00000000 --- a/test/JikanTest/Model/AnimeTest.php +++ /dev/null @@ -1,35 +0,0 @@ -anime = $jikan->getAnime($request); - } - - - /** - * @test - */ - public function it_gets_the_anime_airing(): void - { - self::assertEquals(true,$this->anime->isAiring()); - } -} diff --git a/test/JikanTest/Parser/Anime/AnimeEpisodesParserTest.php b/test/JikanTest/Parser/Anime/AnimeEpisodesParserTest.php index 7152e0a7..85432bfc 100644 --- a/test/JikanTest/Parser/Anime/AnimeEpisodesParserTest.php +++ b/test/JikanTest/Parser/Anime/AnimeEpisodesParserTest.php @@ -149,7 +149,7 @@ public function it_gets_episode_forum_url(): void public function it_gets_episodes_score(): void { self::assertEquals( - 4.4, + 4.3, $this->parser->getEpisodes()[0]->getScore() ); } diff --git a/test/JikanTest/Parser/Anime/AnimeParserTest.php b/test/JikanTest/Parser/Anime/AnimeParserTest.php index d65c6760..c992d798 100644 --- a/test/JikanTest/Parser/Anime/AnimeParserTest.php +++ b/test/JikanTest/Parser/Anime/AnimeParserTest.php @@ -1,7 +1,4 @@ -parser->getScoredBy() ); } @@ -306,7 +303,7 @@ public function it_gets_the_anime_scored_by(): void public function it_gets_the_anime_rank(): void { self::assertEquals( - 311, + 308, $this->parser->getRank() ); } @@ -317,7 +314,7 @@ public function it_gets_the_anime_rank(): void public function it_gets_the_anime_popularity(): void { self::assertEquals( - 242, + 243, $this->parser->getPopularity() ); } @@ -328,7 +325,7 @@ public function it_gets_the_anime_popularity(): void public function it_gets_the_anime_members(): void { self::assertEquals( - 658778, + 678927, $this->parser->getMembers() ); } @@ -339,7 +336,7 @@ public function it_gets_the_anime_members(): void public function it_gets_the_anime_favorites(): void { self::assertEquals( - 13235, + 13750, $this->parser->getFavorites() ); } @@ -350,7 +347,7 @@ public function it_gets_the_anime_favorites(): void public function it_gets_the_anime_related(): void { $related = $this->parser->getRelated(); - self::assertCount(2, $related); + self::assertCount(3, $related); self::assertContainsOnlyInstancesOf(MalUrl::class, $related['Adaptation']); } @@ -400,6 +397,6 @@ public function it_gets_the_preview_video() public function it_gets_the_streaming_links() { $streamingLinks = $this->parser->getStreamingLinks(); - self::assertEquals('https://www.funimation.com/shows/trigun', $streamingLinks[0]->getUrl()); + self::assertEquals('http://www.crunchyroll.com/series-275669', $streamingLinks[0]->getUrl()); } } diff --git a/test/JikanTest/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php b/test/JikanTest/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php index 3b65f5ad..3f94feb9 100644 --- a/test/JikanTest/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php +++ b/test/JikanTest/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php @@ -37,7 +37,7 @@ public function it_gets_recently_updated_by_users_count(): void public function it_gets_username(): void { self::assertEquals( - "Docorum", + "KyouTorii", $this->model->getResults()[0]->getUser()->getUsername() ); } @@ -49,7 +49,7 @@ public function it_gets_username(): void public function it_gets_url(): void { self::assertEquals( - "https://myanimelist.net/profile/Docorum", + "https://myanimelist.net/profile/KyouTorii", $this->model->getResults()[0]->getUser()->getUrl() ); } @@ -61,7 +61,7 @@ public function it_gets_url(): void public function it_gets_image_url(): void { self::assertEquals( - "https://cdn.myanimelist.net/images/questionmark_50.gif", + "https://cdn.myanimelist.net/images/userimages/15361140.jpg?t=1664641200", $this->model->getResults()[0]->getUser()->getImages()->getJpg()->getImageUrl() ); } @@ -82,7 +82,7 @@ public function it_gets_score(): void public function it_gets_status(): void { self::assertEquals( - "Watching", + "Plan to Watch", $this->model->getResults()[0]->getStatus() ); } @@ -94,7 +94,7 @@ public function it_gets_status(): void public function it_gets_episodes_seen(): void { self::assertEquals( - 5, + null, $this->model->getResults()[0]->getEpisodesSeen() ); } @@ -106,7 +106,7 @@ public function it_gets_episodes_seen(): void public function it_gets_episodes_total(): void { self::assertEquals( - 26, + null, $this->model->getResults()[0]->getEpisodesTotal() ); } @@ -124,4 +124,4 @@ public function it_gets_date(): void } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Anime/AnimeRecommendationParserTest.php b/test/JikanTest/Parser/Anime/AnimeRecommendationParserTest.php index a2b607a4..4513fb73 100644 --- a/test/JikanTest/Parser/Anime/AnimeRecommendationParserTest.php +++ b/test/JikanTest/Parser/Anime/AnimeRecommendationParserTest.php @@ -27,7 +27,7 @@ public function setUp(): void */ public function it_get_recommendations_count(): void { - self::assertCount(132, $this->model); + self::assertCount(131, $this->model); } /** @@ -94,10 +94,10 @@ public function it_gets_title(): void public function it_gets_recommendation_count(): void { self::assertCount( - 132, + 131, $this->model ); } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Anime/AnimeReviewsParserTest.php b/test/JikanTest/Parser/Anime/AnimeReviewsParserTest.php index 9661280f..6440e9b7 100644 --- a/test/JikanTest/Parser/Anime/AnimeReviewsParserTest.php +++ b/test/JikanTest/Parser/Anime/AnimeReviewsParserTest.php @@ -6,6 +6,7 @@ use Jikan\Parser\Anime\AnimeReviewsParser; use Jikan\Request\Anime\AnimeReviewsRequest; use JikanTest\TestCase; +use Symfony\Component\HttpClient\HttpClient; class AnimeReviewsParserTest extends TestCase { @@ -61,15 +62,6 @@ public function it_gets_review_url(): void self::assertEquals('https://myanimelist.net/reviews.php?id=7406', $this->review->getUrl()); } - /** - * @test - * @covers \Jikan\Parser\Anime\AnimeReviewsParser - */ - public function it_gets_review_votes_count(): void - { - self::assertEquals(2034, $this->review->getVotes()); - } - /** * @test * @covers \Jikan\Parser\Anime\AnimeReviewsParser @@ -98,7 +90,7 @@ public function it_gets_reviewer_username(): void public function it_gets_reviewer_image_url(): void { self::assertEquals( - 'https://cdn.myanimelist.net/images/userimages/11081.jpg?t=1654492800', + 'https://cdn.myanimelist.net/images/userimages/11081.jpg?t=1666216200', $this->review->getUser()->getImages()->getJpg()->getImageUrl() ); } @@ -122,7 +114,7 @@ public function it_gets_reviewer_url(): void public function it_gets_reviewer_episodes_watched(): void { self::assertEquals( - 26, + null, $this->review->getEpisodesWatched() ); } @@ -131,14 +123,16 @@ public function it_gets_reviewer_episodes_watched(): void * @test * @covers \Jikan\Parser\Anime\AnimeReviewsParser */ - public function it_gets_reviewer_scores(): void + public function it_gets_reviewer_reactions(): void { - self::assertEquals(10, $this->review->getScores()->getOverall()); - self::assertEquals(10, $this->review->getScores()->getStory()); - self::assertEquals(9, $this->review->getScores()->getAnimation()); - self::assertEquals(10, $this->review->getScores()->getSound()); - self::assertEquals(10, $this->review->getScores()->getCharacter()); - self::assertEquals(9, $this->review->getScores()->getEnjoyment()); + self::assertEquals(2, $this->review->getReactions()->getLoveIt()); + self::assertEquals(0, $this->review->getReactions()->getCreative()); + self::assertEquals(0, $this->review->getReactions()->getWellWritten()); + self::assertEquals(0, $this->review->getReactions()->getInformative()); + self::assertEquals(0, $this->review->getReactions()->getConfusing()); + self::assertEquals(1, $this->review->getReactions()->getFunny()); + self::assertEquals(2087, $this->review->getReactions()->getNice()); + self::assertEquals(2090, $this->review->getReactions()->getOverall()); } /** @@ -158,4 +152,4 @@ public function it_gets_reviewer_review(): void } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Anime/AnimeStatsParserTest.php b/test/JikanTest/Parser/Anime/AnimeStatsParserTest.php index 4ce612d0..43be6230 100644 --- a/test/JikanTest/Parser/Anime/AnimeStatsParserTest.php +++ b/test/JikanTest/Parser/Anime/AnimeStatsParserTest.php @@ -44,7 +44,7 @@ public function it_gets_numeric_statistics() public function it_gets_score_attributes() { self::assertEquals( - 1013, + 1062, $this->animeStatsParser->getScores()[10]->getVotes() ); } diff --git a/test/JikanTest/Parser/Character/CharacterListItemParserTest.php b/test/JikanTest/Parser/Character/CharacterListItemParserTest.php index 2641cb7b..df01e2c3 100644 --- a/test/JikanTest/Parser/Character/CharacterListItemParserTest.php +++ b/test/JikanTest/Parser/Character/CharacterListItemParserTest.php @@ -79,7 +79,7 @@ public function it_gets_the_voice_actors() { $voiceActors = $this->parser->getVoiceActors(); self::assertContainsOnly(VoiceActor::class, $voiceActors); - self::assertCount(5, $voiceActors); + self::assertCount(6, $voiceActors); self::assertEquals('Hara, Yumi', $voiceActors[0]->getPerson()->getName()); self::assertEquals('Japanese', $voiceActors[0]->getLanguage()); self::assertEquals('Maxwell, Elizabeth', $voiceActors[1]->getPerson()->getName()); @@ -96,7 +96,7 @@ public function it_gets_the_voice_actors() public function it_gets_the_favorites_count() { self::assertEquals( - 6724, + 7606, $this->parser->getFavorites() ); } diff --git a/test/JikanTest/Parser/Character/CharacterParserTest.php b/test/JikanTest/Parser/Character/CharacterParserTest.php index 662c3859..6b2b5a29 100644 --- a/test/JikanTest/Parser/Character/CharacterParserTest.php +++ b/test/JikanTest/Parser/Character/CharacterParserTest.php @@ -81,7 +81,7 @@ public function it_gets_the_about() */ public function it_gets_the_member_favorites() { - self::assertEquals(11523, $this->parser->getMemberFavorites()); + self::assertEquals(12474, $this->parser->getMemberFavorites()); } /** diff --git a/test/JikanTest/Parser/Club/ClubParserTest.php b/test/JikanTest/Parser/Club/ClubParserTest.php index 54afff42..8fc148ed 100644 --- a/test/JikanTest/Parser/Club/ClubParserTest.php +++ b/test/JikanTest/Parser/Club/ClubParserTest.php @@ -78,7 +78,7 @@ public function it_gets_title(): void public function it_gets_members_count(): void { self::assertEquals( - 1378, + 1381, $this->parser->getMembersCount() ); } @@ -197,4 +197,4 @@ public function it_gets_character_relations(): void ); } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Forum/ForumTopicParserTest.php b/test/JikanTest/Parser/Forum/ForumTopicParserTest.php index bea5da5e..0e0e0480 100644 --- a/test/JikanTest/Parser/Forum/ForumTopicParserTest.php +++ b/test/JikanTest/Parser/Forum/ForumTopicParserTest.php @@ -2,7 +2,7 @@ /** @noinspection PhpCSValidationInspection */ -namespace JikanTest\Parser\Anime; +namespace JikanTest\Parser\Forum; use Jikan\Model\Forum\ForumPost; use Jikan\Parser\Forum\ForumTopicParser; @@ -32,7 +32,7 @@ public function setUp(): void */ public function it_gets_the_post_id(): void { - self::assertEquals(29264, $this->parser->getTopicId()); + self::assertEquals(24885, $this->parser->getTopicId()); } /** @@ -40,7 +40,7 @@ public function it_gets_the_post_id(): void */ public function it_gets_the_post_url(): void { - self::assertEquals('https://myanimelist.net/forum/?topicid=29264', $this->parser->getUrl()); + self::assertEquals('https://myanimelist.net/forum/?topicid=24885', $this->parser->getUrl()); } /** @@ -48,7 +48,7 @@ public function it_gets_the_post_url(): void */ public function it_gets_the_post_title(): void { - self::assertEquals('Cowboy Bebop Episode 1 Discussion', $this->parser->getTitle()); + self::assertEquals('Cowboy Bebop Episode 18 Discussion', $this->parser->getTitle()); } /** @@ -56,7 +56,7 @@ public function it_gets_the_post_title(): void */ public function it_gets_the_post_date(): void { - self::assertEquals('2008-06-13', $this->parser->getPostDate()->format('Y-m-d')); + self::assertEquals('2008-05-14', $this->parser->getPostDate()->format('Y-m-d')); } /** @@ -64,7 +64,7 @@ public function it_gets_the_post_date(): void */ public function it_gets_the_author_name(): void { - self::assertEquals('ManU-Alchemist', $this->parser->getAuthorName()); + self::assertEquals('FighterZ', $this->parser->getAuthorName()); } /** @@ -72,7 +72,7 @@ public function it_gets_the_author_name(): void */ public function it_gets_the_author_url(): void { - self::assertEquals('https://myanimelist.net/profile/ManU-Alchemist', $this->parser->getAuthorUrl()); + self::assertEquals('https://myanimelist.net/profile/FighterZ', $this->parser->getAuthorUrl()); } /** @@ -80,7 +80,7 @@ public function it_gets_the_author_url(): void */ public function it_gets_the_replies(): void { - self::assertEquals(171, $this->parser->getReplies()); + self::assertEquals(160, $this->parser->getReplies()); } /** @@ -90,10 +90,10 @@ public function it_gets_the_last_post(): void { $lastPost = $this->parser->getLastPost(); self::assertInstanceOf(ForumPost::class, $lastPost); - self::assertEquals('princedarkly77', $lastPost->getAuthorUsername()); - self::assertEquals('https://myanimelist.net/profile/princedarkly77', $lastPost->getAuthorUrl()); - self::assertEquals('https://myanimelist.net/forum/?topicid=29264&goto=lastpost', $lastPost->getUrl()); + self::assertEquals('Daiko', $lastPost->getAuthorUsername()); + self::assertEquals('https://myanimelist.net/profile/Daiko', $lastPost->getAuthorUrl()); + self::assertEquals('https://myanimelist.net/forum/?topicid=24885&goto=lastpost', $lastPost->getUrl()); // Last post is 'by Today, 6:29 AM, so just check hour, not day - self::assertEquals('03:41', $lastPost->getDate()->format('H:i')); + self::assertEquals('17:21', $lastPost->getDate()->format('H:i')); } } diff --git a/test/JikanTest/Parser/Genre/AnimeGenreParserTest.php b/test/JikanTest/Parser/Genre/AnimeGenreParserTest.php index e62fe532..9bca78ee 100644 --- a/test/JikanTest/Parser/Genre/AnimeGenreParserTest.php +++ b/test/JikanTest/Parser/Genre/AnimeGenreParserTest.php @@ -49,7 +49,7 @@ public function it_gets_anime() */ public function it_gets_the_count() { - self::assertEquals(4210, $this->parser->getCount()); + self::assertEquals(4369, $this->parser->getCount()); } /** diff --git a/test/JikanTest/Parser/Genre/MangaGenreParserTest.php b/test/JikanTest/Parser/Genre/MangaGenreParserTest.php index 6dced42f..6c966283 100644 --- a/test/JikanTest/Parser/Genre/MangaGenreParserTest.php +++ b/test/JikanTest/Parser/Genre/MangaGenreParserTest.php @@ -50,7 +50,7 @@ public function it_gets_manga() */ public function it_gets_the_count() { - self::assertEquals(7973, $this->parser->getCount()); + self::assertEquals(8332, $this->parser->getCount()); } /** diff --git a/test/JikanTest/Parser/Magazine/MagazineParserTest.php b/test/JikanTest/Parser/Magazine/MagazineParserTest.php index 7c92590b..d2424385 100644 --- a/test/JikanTest/Parser/Magazine/MagazineParserTest.php +++ b/test/JikanTest/Parser/Magazine/MagazineParserTest.php @@ -40,7 +40,7 @@ public function it_gets_url() public function it_gets_manga() { $manga = $this->parser->getResults(); - self::assertCount(67, $manga); + self::assertCount(68, $manga); self::assertContainsOnlyInstancesOf(\Jikan\Model\Common\MangaCard::class, $manga); } } diff --git a/test/JikanTest/Parser/Manga/CharactersParserTest.php b/test/JikanTest/Parser/Manga/CharactersParserTest.php index 77d19a24..c1bae6b7 100644 --- a/test/JikanTest/Parser/Manga/CharactersParserTest.php +++ b/test/JikanTest/Parser/Manga/CharactersParserTest.php @@ -30,7 +30,7 @@ public function setUp(): void public function it_gets_the_manga_characters() { $characters = $this->parser->getCharacters(); - self::assertCount(74, $characters); + self::assertCount(75, $characters); $names = array_map(function ($item) { return $item->getCharacter()->getName(); }, $characters); diff --git a/test/JikanTest/Parser/Manga/MangaParserTest.php b/test/JikanTest/Parser/Manga/MangaParserTest.php index 54c06b68..d21dc5dd 100644 --- a/test/JikanTest/Parser/Manga/MangaParserTest.php +++ b/test/JikanTest/Parser/Manga/MangaParserTest.php @@ -115,8 +115,8 @@ public function it_gets_the_manga_image_url() */ public function it_gets_the_manga_synopsis() { - self::assertEquals( - "Whenever Naruto Uzumaki proclaims that he will someday become the Hokage—a title bestowed upon the best ninja in the Village Hidden in the Leaves—no one takes him seriously. Since birth, Naruto has been shunned and ridiculed by his fellow villagers. But their contempt isn't because Naruto is loud-mouthed, mischievous, or because of his ineptitude in the ninja arts, but because there is a demon inside him. Prior to Naruto's birth, the powerful and deadly Nine-Tailed Fox attacked the village. In order to stop the rampage, the Fourth Hokage sacrificed his life to seal the demon inside the body of the newborn Naruto. And so when he is assigned to Team 7—along with his new teammates Sasuke Uchiha and Sakura Haruno, under the mentorship of veteran ninja Kakashi Hatake—Naruto is forced to work together with other people for the first time in his life. Through undergoing vigorous training and taking on challenging missions, Naruto must learn what it means to work in a team and carve his own route toward becoming a full-fledged ninja recognized by his village. [Written by MAL Rewrite]", + self::assertStringContainsString( + "Whenever Naruto Uzumaki proclaims that he will someday become the Hokage—a title bestowed upon the best ninja in the Village Hidden", $this->parser->getMangaSynopsis() ); } @@ -240,7 +240,7 @@ public function it_gets_the_manga_genre() public function it_gets_the_manga_score() { self::assertEquals( - 8.06, + 8.07, $this->manga->getScore() ); } @@ -251,7 +251,7 @@ public function it_gets_the_manga_score() public function it_gets_the_manga_scored_by() { self::assertEquals( - 250288, + 254718, $this->manga->getScoredBy() ); } @@ -262,7 +262,7 @@ public function it_gets_the_manga_scored_by() public function it_gets_the_manga_rank() { self::assertEquals( - 594, + 577, $this->manga->getRank() ); } @@ -284,7 +284,7 @@ public function it_gets_the_manga_popularity() public function it_gets_the_manga_members() { self::assertEquals( - 377720, + 385378, $this->manga->getMembers() ); } @@ -295,7 +295,7 @@ public function it_gets_the_manga_members() public function it_gets_the_manga_favorites() { self::assertEquals( - 41940, + 42312, $this->manga->getFavorites() ); } @@ -317,11 +317,11 @@ public function it_gets_the_manga_background() { $background = $this->manga->getBackground(); self::assertStringContainsString( - 'Naruto has sold over 220 million copies worldwide as of 2015, making it the 4th highest grossing', + 'Naruto has sold over 250 million copies worldwide as of 2020, making it the 4th highest grossing manga series of all time.', $background ); self::assertStringContainsString( - ' Comics/Planet Manga from May 2007 to June 2015, and again as Naruto Gold edition since July 2015.', + 'The series was published in English by VIZ Media under the Shonen Jump', $background ); } diff --git a/test/JikanTest/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php b/test/JikanTest/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php index dae8dd1a..596a2ec9 100644 --- a/test/JikanTest/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php +++ b/test/JikanTest/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php @@ -37,7 +37,7 @@ public function it_gets_recently_updated_by_users_count(): void public function it_gets_username(): void { self::assertEquals( - "gl4ss", + "Dylanzio", $this->parser->getResults()[6]->getUser()->getUsername() ); } @@ -49,7 +49,7 @@ public function it_gets_username(): void public function it_gets_url(): void { self::assertEquals( - "https://myanimelist.net/profile/gl4ss", + "https://myanimelist.net/profile/Dylanzio", $this->parser->getResults()[6]->getUser()->getUrl() ); } @@ -61,7 +61,7 @@ public function it_gets_url(): void public function it_gets_image_url(): void { self::assertEquals( - "https://cdn.myanimelist.net/images/userimages/11142052.jpg?t=1654525200", + "https://cdn.myanimelist.net/images/userimages/12682629.jpg?t=1664638800", $this->parser->getResults()[6]->getUser()->getImages()->getJpg()->getImageUrl() ); } @@ -94,7 +94,7 @@ public function it_gets_status(): void public function it_gets_chapters_read(): void { self::assertEquals( - 23, + 133, $this->parser->getResults()[6]->getChaptersRead() ); } @@ -146,4 +146,4 @@ public function it_gets_date(): void } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Manga/MangaRecommendationParserTest.php b/test/JikanTest/Parser/Manga/MangaRecommendationParserTest.php index ed6b744d..28dbd5a0 100644 --- a/test/JikanTest/Parser/Manga/MangaRecommendationParserTest.php +++ b/test/JikanTest/Parser/Manga/MangaRecommendationParserTest.php @@ -27,7 +27,7 @@ public function setUp(): void */ public function it_get_recommendations_count(): void { - self::assertCount(44, $this->model); + self::assertCount(46, $this->model); } /** @@ -100,4 +100,4 @@ public function it_gets_votes_count(): void } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Manga/MangaReviewsParserTest.php b/test/JikanTest/Parser/Manga/MangaReviewsParserTest.php index 0479a85b..d1abe3c6 100644 --- a/test/JikanTest/Parser/Manga/MangaReviewsParserTest.php +++ b/test/JikanTest/Parser/Manga/MangaReviewsParserTest.php @@ -61,15 +61,6 @@ public function it_gets_review_url(): void self::assertEquals('https://myanimelist.net/reviews.php?id=11794', $this->review->getUrl()); } - /** - * @test - * @covers \Jikan\Parser\Manga\MangaReviewsParser - */ - public function it_gets_review_votes_count(): void - { - self::assertEquals(411, $this->review->getVotes()); - } - /** * @test * @covers \Jikan\Parser\Manga\MangaReviewsParser @@ -122,7 +113,7 @@ public function it_gets_reviewer_url(): void public function it_gets_reviewer_chapters_read(): void { self::assertEquals( - 162, + null, $this->review->getChaptersRead() ); } @@ -131,13 +122,16 @@ public function it_gets_reviewer_chapters_read(): void * @test * @covers \Jikan\Parser\Manga\MangaReviewsParser */ - public function it_gets_reviewer_scores(): void + public function it_gets_reviewer_reactions(): void { - self::assertEquals(10, $this->review->getScores()->getOverall()); - self::assertEquals(10, $this->review->getScores()->getStory()); - self::assertEquals(9, $this->review->getScores()->getArt()); - self::assertEquals(10, $this->review->getScores()->getCharacter()); - self::assertEquals(10, $this->review->getScores()->getEnjoyment()); + self::assertEquals(0, $this->review->getReactions()->getLoveIt()); + self::assertEquals(0, $this->review->getReactions()->getCreative()); + self::assertEquals(0, $this->review->getReactions()->getWellWritten()); + self::assertEquals(0, $this->review->getReactions()->getInformative()); + self::assertEquals(0, $this->review->getReactions()->getConfusing()); + self::assertEquals(0, $this->review->getReactions()->getFunny()); + self::assertEquals(422, $this->review->getReactions()->getNice()); + self::assertEquals(422, $this->review->getReactions()->getOverall()); } /** @@ -157,4 +151,4 @@ public function it_gets_reviewer_review(): void } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Manga/MangaStatsParserTest.php b/test/JikanTest/Parser/Manga/MangaStatsParserTest.php index d950a2da..1410d2c2 100644 --- a/test/JikanTest/Parser/Manga/MangaStatsParserTest.php +++ b/test/JikanTest/Parser/Manga/MangaStatsParserTest.php @@ -45,7 +45,7 @@ public function it_gets_numeric_statistics() public function it_gets_score_attributes() { self::assertEquals( - 7938, $this->mangaStatsParser->getScores()[10]->getVotes() + 8404, $this->mangaStatsParser->getScores()[10]->getVotes() ); } } diff --git a/test/JikanTest/Parser/News/NewsListItemParserTest.php b/test/JikanTest/Parser/News/NewsListItemParserTest.php index 6697a854..57ffeb29 100644 --- a/test/JikanTest/Parser/News/NewsListItemParserTest.php +++ b/test/JikanTest/Parser/News/NewsListItemParserTest.php @@ -1,6 +1,6 @@ parser->getTitle()); + self::assertEquals("Kentarou Miura's Assistants Resume 'Berserk' Serialization, 'Holyland' Creator Kouji Mori to Supervise", $this->parser->getTitle()); } /** @@ -39,7 +39,7 @@ public function it_gets_the_title(): void */ public function it_gets_the_url(): void { - self::assertEquals('https://myanimelist.net/news/63203251', $this->parser->getUrl()); + self::assertEquals('https://myanimelist.net/news/66547854', $this->parser->getUrl()); } /** @@ -48,7 +48,7 @@ public function it_gets_the_url(): void public function it_gets_the_image(): void { self::assertEquals( - 'https://cdn.myanimelist.net/s/common/uploaded_files/1621492994-97c345f3d0912b89a1207f235274b1a4.jpeg?s=b42ac2bcc10470f9f29e6d4647f4c4fc', + 'https://cdn.myanimelist.net/s/common/uploaded_files/1654587114-bf53f8de5beebd981afec1932486e604.jpeg?s=14bd951b901aa46034b344818e7cbd31', $this->parser->getImage() ); } @@ -58,7 +58,7 @@ public function it_gets_the_image(): void */ public function it_gets_the_date(): void { - self::assertEquals('2021-05-19 21:39', $this->parser->getDate()->format('Y-m-d H:i')); + self::assertEquals('2022-06-07 00:33', $this->parser->getDate()->format('Y-m-d H:i')); } /** @@ -74,7 +74,7 @@ public function it_gets_the_author(): void */ public function it_gets_the_discussion_link(): void { - self::assertEquals('https://myanimelist.net/forum/?topicid=1924224', $this->parser->getDiscussionLink()); + self::assertEquals('https://myanimelist.net/forum/?topicid=2021160', $this->parser->getDiscussionLink()); } /** @@ -83,7 +83,7 @@ public function it_gets_the_discussion_link(): void public function it_gets_the_comments(): void { self::assertEquals( - 437, + 70, $this->parser->getComments() ); } @@ -94,7 +94,7 @@ public function it_gets_the_comments(): void public function it_gets_the_introduction(): void { self::assertStringContainsString( - 'Prolific manga author Kentarou Miura, best known for creating Berserk, died on May 6 at 2:48 p.m. due to an acute aortic dissection.', + "The editorial department of Young Animal announced on Tuesday that the late Kentarou Miura's Berserk manga will resume serialization", $this->parser->getIntro() ); } diff --git a/test/JikanTest/Parser/Person/PersonParserTest.php b/test/JikanTest/Parser/Person/PersonParserTest.php index d38ba9b6..086142aa 100644 --- a/test/JikanTest/Parser/Person/PersonParserTest.php +++ b/test/JikanTest/Parser/Person/PersonParserTest.php @@ -70,11 +70,7 @@ public function it_gets_the_family_name() public function it_gets_the_about() { self::assertStringContainsString( - "She began her voice-acting career in 1999 and has continued her work as a seiyuu for more than a decade.\n", - $this->parser->getPersonAbout() - ); - self::assertStringContainsString( - "Married on June 2, 2014, her 29th birthday.\n", + "Hobbies: piano", $this->parser->getPersonAbout() ); } @@ -84,7 +80,7 @@ public function it_gets_the_about() */ public function it_gets_the_member_favorites() { - self::assertEquals(38067, $this->parser->getPersonFavorites()); + self::assertEquals(38896, $this->parser->getPersonFavorites()); } /** @@ -104,7 +100,7 @@ public function it_gets_the_image() public function it_gets_the_voice_acting_roles() { $voiceActingRoles = $this->parser->getPersonVoiceActingRoles(); - self::assertCount(525, $voiceActingRoles); + self::assertCount(537, $voiceActingRoles); self::assertContainsOnlyInstancesOf(\Jikan\Model\Person\VoiceActingRole::class, $voiceActingRoles); } diff --git a/test/JikanTest/Parser/Producer/ProducerParserTest.php b/test/JikanTest/Parser/Producer/ProducerParserTest.php index a1334ed8..e2daa62e 100644 --- a/test/JikanTest/Parser/Producer/ProducerParserTest.php +++ b/test/JikanTest/Parser/Producer/ProducerParserTest.php @@ -41,7 +41,7 @@ public function it_gets_url() public function it_gets_anime() { $anime = $this->parser->getResults(); - self::assertCount(278, $anime); + self::assertCount(287, $anime); self::assertContainsOnlyInstancesOf(\Jikan\Model\Common\AnimeCard::class, $anime); } @@ -51,7 +51,7 @@ public function it_gets_anime() public function it_gets_image() { self::assertEquals( - 'https://cdn.myanimelist.net/img/common/companies/1.png', + 'https://cdn.myanimelist.net/images/company/1.png', $this->parser->getImages()->getJpg()->getImageUrl() ); } @@ -73,7 +73,7 @@ public function it_gets_established() public function it_gets_favorites() { self::assertEquals( - 1485, + 2251, $this->parser->getFavorites() ); } @@ -95,7 +95,7 @@ public function it_gets_about() public function it_gets_count() { self::assertEquals( - 278, + 287, $this->parser->getAnimeCount() ); } diff --git a/test/JikanTest/Parser/Schedule/ScheduleParserTest.php b/test/JikanTest/Parser/Schedule/ScheduleParserTest.php index 914e4aa5..f1d7ff14 100644 --- a/test/JikanTest/Parser/Schedule/ScheduleParserTest.php +++ b/test/JikanTest/Parser/Schedule/ScheduleParserTest.php @@ -33,7 +33,7 @@ public function it_gets_mondays() { $monday = $this->parser->getShedule('monday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $monday); - self::assertCount(6, $monday); + self::assertCount(9, $monday); } /** @@ -43,7 +43,7 @@ public function it_gets_tuesdays() { $tuesday = $this->parser->getShedule('tuesday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $tuesday); - self::assertCount(6, $tuesday); + self::assertCount(5, $tuesday); } /** @@ -53,7 +53,7 @@ public function it_gets_wednesdays() { $wednesday = $this->parser->getShedule('wednesday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $wednesday); - self::assertCount(9, $wednesday); + self::assertCount(11, $wednesday); } /** @@ -73,7 +73,7 @@ public function it_gets_fridays() { $friday = $this->parser->getShedule('friday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $friday); - self::assertCount(12, $friday); + self::assertCount(9, $friday); } /** @@ -83,7 +83,7 @@ public function it_gets_saturdays() { $saturday = $this->parser->getShedule('saturday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $saturday); - self::assertCount(20, $saturday); + self::assertCount(14, $saturday); } /** @@ -103,7 +103,7 @@ public function it_gets_all() { $all = $this->parser->getShedule('all'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $all); - self::assertCount(120, $all); + self::assertCount(115, $all); } /** diff --git a/test/JikanTest/Parser/Search/AnimeSearchTest.php b/test/JikanTest/Parser/Search/AnimeSearchTest.php index 8e64b6f6..c4db1fd2 100644 --- a/test/JikanTest/Parser/Search/AnimeSearchTest.php +++ b/test/JikanTest/Parser/Search/AnimeSearchTest.php @@ -100,7 +100,7 @@ public function it_gets_the_end_date() */ public function it_gets_the_members() { - self::assertEquals(1003331, $this->anime->getMembers()); + self::assertEquals(1029210, $this->anime->getMembers()); } /** @@ -116,6 +116,6 @@ public function it_gets_the_rated() */ public function it_gets_the_score() { - self::assertEquals(8.57, $this->anime->getScore()); + self::assertEquals(8.56, $this->anime->getScore()); } } diff --git a/test/JikanTest/Parser/Search/MangaSearchTest.php b/test/JikanTest/Parser/Search/MangaSearchTest.php index b2a8da60..12763392 100644 --- a/test/JikanTest/Parser/Search/MangaSearchTest.php +++ b/test/JikanTest/Parser/Search/MangaSearchTest.php @@ -105,7 +105,7 @@ public function it_gets_the_end_date() */ public function it_gets_the_members() { - self::assertEquals($this->manga->getMembers(), 6670); + self::assertEquals($this->manga->getMembers(), 6906); } /** @@ -113,6 +113,6 @@ public function it_gets_the_members() */ public function it_gets_the_score() { - self::assertEquals($this->manga->getScore(), 7.75); + self::assertEquals($this->manga->getScore(), 7.76); } } diff --git a/test/JikanTest/Parser/SeasonList/SeasonListItemParserTest.php b/test/JikanTest/Parser/SeasonList/SeasonListItemParserTest.php index c240140d..81055c3b 100644 --- a/test/JikanTest/Parser/SeasonList/SeasonListItemParserTest.php +++ b/test/JikanTest/Parser/SeasonList/SeasonListItemParserTest.php @@ -28,7 +28,7 @@ public function setUp(): void */ public function it_gets_the_year(): void { - self::assertEquals(2022, $this->parser->getYear()); + self::assertEquals(2023, $this->parser->getYear()); } /** diff --git a/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php b/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php index fb351a62..6626acff 100644 --- a/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php +++ b/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php @@ -118,7 +118,7 @@ public function it_gets_the_air_dates() */ public function it_gets_the_air_members() { - self::assertEquals(19000000, $this->parser->getMembers()); + self::assertEquals(20000000, $this->parser->getMembers()); } /** diff --git a/test/JikanTest/Parser/Seasonal/SeasonalParserTest.php b/test/JikanTest/Parser/Seasonal/SeasonalParserTest.php index 26cfd87b..21fc663b 100644 --- a/test/JikanTest/Parser/Seasonal/SeasonalParserTest.php +++ b/test/JikanTest/Parser/Seasonal/SeasonalParserTest.php @@ -38,7 +38,7 @@ public function it_gets_the_season() public function it_gets_the_anime() { $anime = $this->springParser->getSeasonalAnime(); - self::assertCount(279, $anime); + self::assertCount(290, $anime); self::assertContainsOnlyInstancesOf(\Jikan\Model\Seasonal\SeasonalAnime::class, $anime); } } diff --git a/test/JikanTest/Parser/Top/TopAnimeParserTest.php b/test/JikanTest/Parser/Top/TopAnimeParserTest.php index ab2d9aef..05a43892 100644 --- a/test/JikanTest/Parser/Top/TopAnimeParserTest.php +++ b/test/JikanTest/Parser/Top/TopAnimeParserTest.php @@ -34,8 +34,8 @@ public function setUp(): void public function it_gets_the_mal_url() { $url = $this->parser->getMalUrl(); - self::assertEquals('Ginga Eiyuu Densetsu', $url->getTitle()); - self::assertEquals('https://myanimelist.net/anime/820/Ginga_Eiyuu_Densetsu', $url->getUrl()); + self::assertEquals('Fruits Basket: The Final', $url->getTitle()); + self::assertEquals('https://myanimelist.net/anime/42938/Fruits_Basket__The_Final', $url->getUrl()); } /** @@ -52,7 +52,7 @@ public function it_gets_the_rank() public function it_gets_the_image() { self::assertEquals( - 'https://cdn.myanimelist.net/images/anime/13/13225.jpg?s=385cedad342e284c5765833ab1cddc1c', + 'https://cdn.myanimelist.net/images/anime/1085/114792.jpg?s=bb4303c0804c9d5ca9fcb30b8f8e6783', $this->parser->getImage() ); } @@ -62,7 +62,7 @@ public function it_gets_the_image() */ public function it_gets_the_anime_score() { - self::assertEquals(9.03, $this->parser->getScore()); + self::assertEquals(9.02, $this->parser->getScore()); } /** @@ -70,7 +70,7 @@ public function it_gets_the_anime_score() */ public function it_gets_the_anime_type() { - self::assertEquals('OVA', $this->parser->getType()); + self::assertEquals('TV', $this->parser->getType()); } /** @@ -78,7 +78,7 @@ public function it_gets_the_anime_type() */ public function it_gets_the_anime_episodes() { - self::assertEquals(110, $this->parser->getEpisodes()); + self::assertEquals(13, $this->parser->getEpisodes()); } /** @@ -86,7 +86,7 @@ public function it_gets_the_anime_episodes() */ public function it_gets_the_anime_members() { - self::assertEquals(279994, $this->parser->getMembers()); + self::assertEquals(376544, $this->parser->getMembers()); } /** @@ -94,7 +94,7 @@ public function it_gets_the_anime_members() */ public function it_gets_the_anime_start_date() { - self::assertEquals('Jan 1988', $this->parser->getStartDate()); + self::assertEquals('Apr 2021', $this->parser->getStartDate()); } /** @@ -102,6 +102,6 @@ public function it_gets_the_anime_start_date() */ public function it_gets_the_anime_end_date() { - self::assertEquals('Mar 1997', $this->parser->getEndDate()); + self::assertEquals('Jun 2021', $this->parser->getEndDate()); } } diff --git a/test/JikanTest/Parser/Top/TopCharacterParserTest.php b/test/JikanTest/Parser/Top/TopCharacterParserTest.php index 5e1ae909..57bd0548 100644 --- a/test/JikanTest/Parser/Top/TopCharacterParserTest.php +++ b/test/JikanTest/Parser/Top/TopCharacterParserTest.php @@ -35,8 +35,8 @@ public function setUp(): void public function it_gets_the_mal_url() { $url = $this->parser->getMalUrl(); - self::assertEquals('Lawliet, L', $url->getTitle()); - self::assertEquals('https://myanimelist.net/character/71/L_Lawliet', $url->getUrl()); + self::assertEquals('Monkey D., Luffy', $url->getTitle()); + self::assertEquals('https://myanimelist.net/character/40/Luffy_Monkey_D', $url->getUrl()); } /** @@ -45,7 +45,7 @@ public function it_gets_the_mal_url() public function it_gets_the_image() { self::assertEquals( - 'https://cdn.myanimelist.net/images/characters/10/249647.jpg?s=3a9db4dd560c26d3374eca98d66bcd9a', + 'https://cdn.myanimelist.net/images/characters/9/310307.jpg?s=1422edf1e44c7b6262386330461eecfd', $this->parser->getImage() ); } @@ -63,7 +63,7 @@ public function it_gets_the_rank() */ public function it_gets_the_character_kanji() { - self::assertEquals('エル ローライト', $this->parser->getKanjiName()); + self::assertEquals('モンキー・D・ルフィ', $this->parser->getKanjiName()); } /** @@ -71,7 +71,7 @@ public function it_gets_the_character_kanji() */ public function it_gets_the_animeography() { - self::assertCount(2, $this->parser->getAnimeography()); + self::assertCount(3, $this->parser->getAnimeography()); self::assertContainsOnlyInstancesOf(MalUrl::class, $this->parser->getAnimeography()); } @@ -89,6 +89,6 @@ public function it_gets_the_mangaography() */ public function it_gets_the_favorites() { - self::assertEquals(118434, $this->parser->getFavorites()); + self::assertEquals(121629, $this->parser->getFavorites()); } } diff --git a/test/JikanTest/Parser/Top/TopMangaParserTest.php b/test/JikanTest/Parser/Top/TopMangaParserTest.php index feb65bc6..8d9ef822 100644 --- a/test/JikanTest/Parser/Top/TopMangaParserTest.php +++ b/test/JikanTest/Parser/Top/TopMangaParserTest.php @@ -40,8 +40,8 @@ public function setUp(): void public function it_gets_the_mal_url() { $url = $this->parser->getMalUrl(); - self::assertEquals('Fullmetal Alchemist', $url->getTitle()); - self::assertEquals('https://myanimelist.net/manga/25/Fullmetal_Alchemist', $url->getUrl()); + self::assertEquals('Slam Dunk', $url->getTitle()); + self::assertEquals('https://myanimelist.net/manga/51/Slam_Dunk', $url->getUrl()); } /** @@ -76,7 +76,7 @@ public function it_gets_the_manga_volumes() $parser2 = new TopListItemParser( $this->crawler->filterXPath('//tr[@class="ranking-list"]')->eq(1) ); - self::assertEquals(27, $this->parser->getVolumes()); + self::assertEquals(31, $this->parser->getVolumes()); } /** @@ -84,7 +84,7 @@ public function it_gets_the_manga_volumes() */ public function it_gets_the_manga_members() { - self::assertEquals(260591, $this->parser->getMembers()); + self::assertEquals(138611, $this->parser->getMembers()); } /** @@ -92,7 +92,7 @@ public function it_gets_the_manga_members() */ public function it_gets_the_manga_start_date() { - self::assertEquals('Jul 2001', $this->parser->getStartDate()); + self::assertEquals('Sep 1990', $this->parser->getStartDate()); } /** @@ -100,7 +100,7 @@ public function it_gets_the_manga_start_date() */ public function it_gets_the_manga_end_date() { - self::assertEquals('Sep 2010', $this->parser->getEndDate()); + self::assertEquals('Jun 1996', $this->parser->getEndDate()); } /** @@ -109,7 +109,7 @@ public function it_gets_the_manga_end_date() public function it_gets_the_manga_image() { self::assertEquals( - 'https://cdn.myanimelist.net/images/manga/3/243675.jpg?s=8cb0a643f8a7597514447f2dd0e4ffc2', + 'https://cdn.myanimelist.net/images/manga/2/258749.jpg?s=fad0d2cae56806beefaca50b445fa0dd', $this->parser->getImage() ); } diff --git a/test/JikanTest/Parser/Top/TopPeopleParserTest.php b/test/JikanTest/Parser/Top/TopPeopleParserTest.php index 42a55d82..084fb144 100644 --- a/test/JikanTest/Parser/Top/TopPeopleParserTest.php +++ b/test/JikanTest/Parser/Top/TopPeopleParserTest.php @@ -34,8 +34,8 @@ public function setUp(): void public function it_gets_the_mal_url() { $url = $this->parser->getMalUrl(); - self::assertEquals('Oda, Eiichiro', $url); - self::assertEquals('https://myanimelist.net/people/1881/Eiichiro_Oda', $url->getUrl()); + self::assertEquals('Ono, Daisuke', $url->getName()); + self::assertEquals('https://myanimelist.net/people/212/Daisuke_Ono', $url->getUrl()); } /** @@ -51,7 +51,7 @@ public function it_gets_the_rank() */ public function it_gets_the_favorites() { - self::assertEquals(46179, $this->parser->getPeopleFavorites()); + self::assertEquals(47386, $this->parser->getPeopleFavorites()); } /** @@ -60,7 +60,7 @@ public function it_gets_the_favorites() public function it_gets_the_image() { self::assertEquals( - 'https://cdn.myanimelist.net/images/voiceactors/2/10593.jpg?s=6e83dfc242f5610e419eb59c24aebdc6', + 'https://cdn.myanimelist.net/images/voiceactors/1/54593.jpg?s=3c92b9a278bb1fb08cf7f0f3f2ec7bee', $this->parser->getImage() ); } @@ -71,7 +71,7 @@ public function it_gets_the_image() public function it_gets_the_kanji_name() { self::assertEquals( - '尾田 栄一郎', + '小野 大輔', $this->parser->getKanjiName() ); } @@ -82,7 +82,7 @@ public function it_gets_the_kanji_name() public function it_gets_the_birthday() { self::assertEquals( - '1975-01-01', + '1978-05-04', $this->parser->getBirthday()->format('Y-m-d') ); } diff --git a/test/JikanTest/Parser/UserFriend/FriendParserTest.php b/test/JikanTest/Parser/UserFriend/FriendParserTest.php index d70929ae..13069f0a 100644 --- a/test/JikanTest/Parser/UserFriend/FriendParserTest.php +++ b/test/JikanTest/Parser/UserFriend/FriendParserTest.php @@ -29,7 +29,7 @@ public function setUp(): void */ public function it_gets_the_name() { - self::assertEquals('batsling1234', $this->parser->getName()); + self::assertEquals('EmperorKaido', $this->parser->getName()); } /** @@ -37,7 +37,7 @@ public function it_gets_the_name() */ public function it_gets_the_url() { - self::assertEquals('https://myanimelist.net/profile/batsling1234', $this->parser->getUrl()); + self::assertEquals('https://myanimelist.net/profile/EmperorKaido', $this->parser->getUrl()); } /** @@ -46,7 +46,7 @@ public function it_gets_the_url() public function it_gets_the_avatar() { self::assertEquals( - 'https://cdn.myanimelist.net/images/userimages/4723677.jpg?t=1654526400', + 'https://cdn.myanimelist.net/images/userimages/5229794.jpg?t=1664642400', $this->parser->getAvatar() ); } @@ -57,7 +57,7 @@ public function it_gets_the_avatar() public function it_gets_friends_since() { self::assertEquals( - '2019-08-03 18:25', + '2019-11-14 12:08', $this->parser->getFriendsSince()->format('Y-m-d H:i') ); } @@ -68,4 +68,4 @@ public function it_gets_last_online() { self::assertInstanceOf(\DateTimeImmutable::class, $this->parser->getLastOnline()); } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/UserProfile/UserProfileParserTest.php b/test/JikanTest/Parser/UserProfile/UserProfileParserTest.php index 11e5ad4e..36caca32 100644 --- a/test/JikanTest/Parser/UserProfile/UserProfileParserTest.php +++ b/test/JikanTest/Parser/UserProfile/UserProfileParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\User\Profile; +use Jikan\Parser\User\Profile\UserProfileParser; use JikanTest\TestCase; /** @@ -10,9 +11,9 @@ class UserProfileParserTest extends TestCase { /** - * @var \Jikan\Parser\User\Profile\UserProfileParser + * @var UserProfileParser */ - private $parser; + private UserProfileParser $parser; public function setUp(): void { @@ -20,7 +21,7 @@ public function setUp(): void $client = new \Goutte\Client($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/profile/sandshark'); - $this->parser = new \Jikan\Parser\User\Profile\UserProfileParser($crawler); + $this->parser = new UserProfileParser($crawler); } /** @@ -45,7 +46,7 @@ public function it_gets_the_url() public function it_gets_the_image() { self::assertEquals( - 'https://cdn.myanimelist.net/images/userimages/3600201.jpg?t=1653853200', + 'https://cdn.myanimelist.net/images/userimages/3600201.jpg?t=1664231400', $this->parser->getImageUrl() ); } diff --git a/test/JikanTest/TestCase.php b/test/JikanTest/TestCase.php index f7706cf6..707089ed 100644 --- a/test/JikanTest/TestCase.php +++ b/test/JikanTest/TestCase.php @@ -4,13 +4,14 @@ use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\MockHttpClient; +use Symfony\Contracts\HttpClient\HttpClientInterface; abstract class TestCase extends \PHPUnit\Framework\TestCase { /** - * @var \Symfony\Contracts\HttpClient\HttpClientInterface + * @var HttpClientInterface */ - protected $httpClient; + protected HttpClientInterface|MockHttpClient $httpClient; protected function setUp(): void { @@ -23,4 +24,4 @@ protected function setUp(): void ); $this->httpClient = new MockHttpClient(new HttpFilesystemCacheClientCallback($cachePath)); } -} \ No newline at end of file +}