diff --git a/.github/workflows/archive.yaml b/.github/workflows/archive.yaml index 3d639889..b7328482 100644 --- a/.github/workflows/archive.yaml +++ b/.github/workflows/archive.yaml @@ -6,7 +6,7 @@ on: jobs: archive: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/stale@v5.0.0 with: diff --git a/.github/workflows/code-quality-pr.yaml b/.github/workflows/code-quality-pr.yaml index 98b9e363..a717978e 100644 --- a/.github/workflows/code-quality-pr.yaml +++ b/.github/workflows/code-quality-pr.yaml @@ -5,7 +5,7 @@ on: jobs: codeQuality: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 name: PHP steps: - name: Checkout changes @@ -15,7 +15,7 @@ jobs: - name: Setup PHP and linter uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.2' tools: parallel-lint, phpunit, php-cs-fixer - name: Run code quality checks run: ./.github/workflows/utilities/lint-pr ${{ github.base_ref }} diff --git a/.github/workflows/code-quality-push.yaml b/.github/workflows/code-quality-push.yaml index 181056ab..7795be54 100644 --- a/.github/workflows/code-quality-push.yaml +++ b/.github/workflows/code-quality-push.yaml @@ -7,7 +7,7 @@ on: jobs: codeQuality: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 name: PHP steps: - name: Checkout changes @@ -17,7 +17,7 @@ jobs: - name: Setup PHP and linter uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.2' tools: parallel-lint, phpunit, php-cs-fixer - name: Run code quality checks run: ./.github/workflows/utilities/lint-push diff --git a/.github/workflows/comment-run.yaml b/.github/workflows/comment-run.yaml index 5f4ba855..1b74266c 100644 --- a/.github/workflows/comment-run.yaml +++ b/.github/workflows/comment-run.yaml @@ -5,7 +5,7 @@ on: jobs: comment-run: - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2f0009dc..04759e65 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -11,8 +11,8 @@ jobs: strategy: max-parallel: 4 matrix: - operatingSystem: [ubuntu-20.04, windows-latest] - phpVersion: ['8.0', '8.1'] + operatingSystem: [ubuntu-22.04, windows-latest] + phpVersion: ['8.2'] fail-fast: false runs-on: ${{ matrix.operatingSystem }} name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }} diff --git a/.gitignore b/.gitignore index 7e75b14c..b460efcb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ /.php-cs-fixer.cache composer.phar .phpunit.result.cache +.phpdoc +.phive diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 1c810f73..8e7edce9 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -6,7 +6,9 @@ return (new PhpCsFixer\Config()) ->setRules([ - '@PSR2' => true, + '@PSR12' => true, + '@PER-CS' => true, + '@PHP82Migration' => true, 'array_syntax' => ['syntax' => 'short'], ]) ->setFinder($finder) diff --git a/LICENSE b/LICENSE index 175312a2..4fba5532 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Jikan API +Copyright (c) 2018-2024 Jikan API Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index bfdd382b..43a97f41 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "minimum-stability": "stable", "authors": [ { - "name": "Irfan", + "name": "Nekomata", "email": "neko@jikan.moe" } ], @@ -19,24 +19,25 @@ }, "autoload-dev": { "psr-4": { - "JikanTest\\": [ - "test/JikanTest" - ] + "JikanTest\\": [ + "test/unit" + ] } }, "require": { - "php": "^8.0", + "php": "^8.2", "ext-json": "*", - "fabpot/goutte": "^4.0" + "symfony/browser-kit": "^6.4", + "symfony/css-selector": "^6.4", + "symfony/http-client": "^6.4" }, "require-dev": { - "brianium/paratest": "^6.4.1", + "brianium/paratest": "^7.3", "doctrine/collections": "^1.5", "friendsofphp/php-cs-fixer": "^3.8", - "php-parallel-lint/php-parallel-lint": "^1.3", "jikan-me/jikan-fixtures": "dev-master", - "phpro/grumphp": "^1.7.0", - "phpunit/phpunit": "~9.0", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpro/grumphp": "^2.4", "squizlabs/php_codesniffer": "^3.3" }, "scripts": { @@ -46,6 +47,10 @@ "composer config repositories.fixtures path ../jikan-fixtures", "composer update jikan-me/jikan-fixtures", "composer config repositories.fixtures --unset" + ], + "generate-docs": [ + "git clone https://github.com/jikan-me/jikan-docs.git ../jikan-docs || git -C ../jikan-docs reset --hard origin/master", + "phpDocumentor run -d src -t ../jikan-docs/docs" ] }, "config": { diff --git a/grumphp.yml b/grumphp.yml index 31f39c39..f803d4fc 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -13,4 +13,4 @@ grumphp: - 'die' paratest: always_execute: true - phplint: ~ \ No newline at end of file + phplint: ~ diff --git a/phpunit.xml b/phpunit.xml index 5a0d5699..a9782dd1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,22 @@ - - - - - src - - + + - - ./test/JikanTest + + test/unit + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 91c5793b..ed2efffa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - ./test/JikanTest + ./test/unit @@ -9,4 +9,4 @@ src - \ No newline at end of file + diff --git a/src/Exception/BadResponseException.php b/src/Exception/BadResponseException.php index d045f8eb..5c06fd8f 100644 --- a/src/Exception/BadResponseException.php +++ b/src/Exception/BadResponseException.php @@ -7,6 +7,4 @@ * * @package Jikan\Exception */ -class BadResponseException extends \Exception -{ -} +class BadResponseException extends \Exception {} diff --git a/src/Helper/JString.php b/src/Helper/JString.php index e3408a9e..536f2093 100644 --- a/src/Helper/JString.php +++ b/src/Helper/JString.php @@ -30,15 +30,15 @@ public static function cleanse(string $string): string $string = preg_replace('~[[:cntrl:]]~', "", $string); // strip any leftover tags -// $string = htmlspecialchars_decode(strip_tags($string)); + // $string = htmlspecialchars_decode(strip_tags($string)); $string = strip_tags($string); // trim Nbsp // causing serializer issues -// $string = self::UTF8NbspTrim($string); + // $string = self::UTF8NbspTrim($string); // remove any newlines at the end $string = str_replace('\\n', "\n", $string); -// $string = preg_replace('~([\n]+)~', '', $string); + // $string = preg_replace('~([\n]+)~', '', $string); // trim $string = trim($string); @@ -52,14 +52,14 @@ public static function cleanse(string $string): string */ public static function UTF8NbspTrim(string $string): string { - return trim($string, \chr(0xC2).\chr(0xA0)); + return trim($string, \chr(0xC2) . \chr(0xA0)); } /** * @param string $string * @return string */ - public static function strToCanonical(string $string) : string + public static function strToCanonical(string $string): string { return str_replace( [' ', '/'], diff --git a/src/Helper/Media.php b/src/Helper/Media.php index 2a29be50..f3034bfa 100644 --- a/src/Helper/Media.php +++ b/src/Helper/Media.php @@ -15,7 +15,7 @@ class Media * @param string|null $url * @return string */ - public static function youtubeIdFromUrl(?string $url) : ?string + public static function youtubeIdFromUrl(?string $url): ?string { /** * https://stackoverflow.com/a/17030234 @@ -38,7 +38,7 @@ public static function youtubeIdFromUrl(?string $url) : ?string * @param string $id * @return string */ - public static function generateYoutubeUrlFromId(?string $id) : ?string + public static function generateYoutubeUrlFromId(?string $id): ?string { if ($id === null) { return null; @@ -51,7 +51,7 @@ public static function generateYoutubeUrlFromId(?string $id) : ?string * @param string $id * @return YoutubeImageResource */ - public static function generateYoutubeImageResource(?string $id) : YoutubeImageResource + public static function generateYoutubeImageResource(?string $id): YoutubeImageResource { return YoutubeImageResource::factory($id); } diff --git a/src/Helper/Parser.php b/src/Helper/Parser.php index dddab031..f2b69b9c 100644 --- a/src/Helper/Parser.php +++ b/src/Helper/Parser.php @@ -48,7 +48,7 @@ function (Crawler $crawler) { */ public static function idFromUrl(string $url): int { - return (int)preg_replace('#https://myanimelist.net(/\w+/)(\d+).*#', '$2', $url); + return (int) preg_replace('#https://myanimelist.net(/\w+/)(\d+).*#', '$2', $url); } /** @@ -57,7 +57,7 @@ public static function idFromUrl(string $url): int * @param string $url * @return int */ - public static function clubIdFromUrl(string $url) : int + public static function clubIdFromUrl(string $url): int { return (int) preg_replace('~.*\.php\?cid=([\d]+)$~', '$1', $url); } @@ -82,7 +82,7 @@ public static function suffixIdFromUrl(string $url): int public static function parseForumDate(string $date): ?\DateTimeImmutable { if (!preg_match('/\d{4}/', $date)) { - $date .= ', '.date('Y'); + $date .= ', ' . date('Y'); } return self::parseDate($date); @@ -96,7 +96,7 @@ public static function parseForumDate(string $date): ?\DateTimeImmutable public static function parseDate(string $date): ?\DateTimeImmutable { if (preg_match('/^\d{4}$/', $date)) { - return \DateTimeImmutable::createFromFormat('!Y-m-d', $date.'-01-01', new \DateTimeZone('UTC')); + return \DateTimeImmutable::createFromFormat('!Y-m-d', $date . '-01-01', new \DateTimeZone('UTC')); } if (preg_match('/(\w{3}), (\d{4})/', $date, $matches)) { @@ -185,7 +185,7 @@ public static function parseDateMDYReadable(string $date): ?\DateTimeImmutable * @param string $dateTime * @return \DateTimeImmutable|null */ - public static function parseDateTimePST(string $dateTime) : ?\DateTimeImmutable + public static function parseDateTimePST(string $dateTime): ?\DateTimeImmutable { try { $malTimeZone = new \DateTimeZone('America/Los_Angeles'); // @@ -217,7 +217,7 @@ public static function textOrNull(Crawler $crawler): ?string * @return string * @throws \InvalidArgumentException */ - public static function parseImageQuality(string $imageUrl) : string + public static function parseImageQuality(string $imageUrl): string { // adding `v` prefix returns a very small thumbnail, as opposed to adding `l` $imageUrl = str_replace(['v.jpg', 't.jpg', 'l.jpg'], '.jpg', $imageUrl); @@ -230,7 +230,7 @@ public static function parseImageQuality(string $imageUrl) : string * @return string * @throws \InvalidArgumentException */ - public static function parseImageThumbToHQ(string $imageUrl) : string + public static function parseImageThumbToHQ(string $imageUrl): string { return str_replace(['thumbs/', '_thumb'], '', $imageUrl); } @@ -250,6 +250,6 @@ public static function parseDurationToSeconds(string $duration): ?int $minutes = $match[2] ?? 0; $seconds = $match[3] ?? 0; - return ($hours*60*60) + ($minutes*60) + $seconds; + return ($hours * 60 * 60) + ($minutes * 60) + $seconds; } } diff --git a/src/Goutte/GoutteWrapper.php b/src/Http/HttpClientWrapper.php similarity index 81% rename from src/Goutte/GoutteWrapper.php rename to src/Http/HttpClientWrapper.php index 4bb4efee..d3888ef3 100644 --- a/src/Goutte/GoutteWrapper.php +++ b/src/Http/HttpClientWrapper.php @@ -1,17 +1,17 @@ getInternalResponse(); if ($internalResponse->getStatusCode() >= 400) { throw new BadResponseException( - $internalResponse->getStatusCode().' on '.$response->getUri(), + $internalResponse->getStatusCode() . ' on ' . $response->getUri(), $internalResponse->getStatusCode() ); } diff --git a/src/Model/Anime/AnimeReviews.php b/src/Model/Anime/AnimeReviews.php index bc521a91..a2bea25d 100644 --- a/src/Model/Anime/AnimeReviews.php +++ b/src/Model/Anime/AnimeReviews.php @@ -36,7 +36,7 @@ public static function fromParser(Parser\Anime\AnimeReviewsParser $parser): self /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Anime/AnimeUserUpdates.php b/src/Model/Anime/AnimeUserUpdates.php index 4138595c..ecb7ee8a 100644 --- a/src/Model/Anime/AnimeUserUpdates.php +++ b/src/Model/Anime/AnimeUserUpdates.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Anime\AnimeRecentlyUpdatedByUsersParser return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Anime/AnimeVideosEpisodes.php b/src/Model/Anime/AnimeVideosEpisodes.php index 3552295a..682c5da7 100644 --- a/src/Model/Anime/AnimeVideosEpisodes.php +++ b/src/Model/Anime/AnimeVideosEpisodes.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Anime\VideosParser $parser): self /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Anime/Episodes.php b/src/Model/Anime/Episodes.php index 9927a5d2..e7f610f8 100644 --- a/src/Model/Anime/Episodes.php +++ b/src/Model/Anime/Episodes.php @@ -43,7 +43,7 @@ public static function fromParser(EpisodesParser $parser): self /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Club/Club.php b/src/Model/Club/Club.php index b642d0aa..0b3f9fc0 100644 --- a/src/Model/Club/Club.php +++ b/src/Model/Club/Club.php @@ -87,7 +87,7 @@ public static function fromParser(ClubParser $parser): Club $instance->name = $parser->getTitle(); $instance->images = ClubImageResource::factory($parser->getImageUrl()); $instance->members = $parser->getMembersCount(); -// $instance->picturesCount = $parser->getPicturesCount(); + // $instance->picturesCount = $parser->getPicturesCount(); $instance->category = $parser->getCategory(); $instance->created = $parser->getCreated(); $instance->anime = $parser->getAnimeRelations(); diff --git a/src/Model/Club/UserList.php b/src/Model/Club/UserList.php index 2b4ba9ef..69e0db1b 100644 --- a/src/Model/Club/UserList.php +++ b/src/Model/Club/UserList.php @@ -45,7 +45,7 @@ public static function fromParser(UserListParser $parser): self /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Common/AnimeCard.php b/src/Model/Common/AnimeCard.php index d52c1de5..1c41471b 100644 --- a/src/Model/Common/AnimeCard.php +++ b/src/Model/Common/AnimeCard.php @@ -181,7 +181,7 @@ public function getDemographics(): array */ public function __toString() { - return (string)$this->url; + return (string) $this->url; } /** diff --git a/src/Model/Common/ClubMeta.php b/src/Model/Common/ClubMeta.php index 3402587a..2d79ca5f 100644 --- a/src/Model/Common/ClubMeta.php +++ b/src/Model/Common/ClubMeta.php @@ -29,9 +29,9 @@ class ClubMeta * @param string $url * @return ClubMeta */ - public static function factory(int $malId, string $name, string $url) : self + public static function factory(int $malId, string $name, string $url): self { - $instance = new self; + $instance = new self(); $instance->malId = $malId; $instance->name = $name; diff --git a/src/Model/Common/Collection/Pagination.php b/src/Model/Common/Collection/Pagination.php index 68ff5c00..58699872 100644 --- a/src/Model/Common/Collection/Pagination.php +++ b/src/Model/Common/Collection/Pagination.php @@ -15,10 +15,10 @@ interface Pagination /** * @return bool */ - public function hasNextPage() : bool; + public function hasNextPage(): bool; /** * @return int|null */ - public function getLastVisiblePage() : ?int; + public function getLastVisiblePage(): ?int; } diff --git a/src/Model/Common/DateProp.php b/src/Model/Common/DateProp.php index e73d7e29..ad4d6135 100644 --- a/src/Model/Common/DateProp.php +++ b/src/Model/Common/DateProp.php @@ -61,7 +61,7 @@ public static function fromDateTime(?\DateTimeImmutable $dateTimeImmutable): Dat /** * @param string $date */ - private function parse(string $date) : void + private function parse(string $date): void { if (preg_match('/^\d{4}$/', $date)) { $this->set(null, null, (int) $date); @@ -97,7 +97,7 @@ private function parse(string $date) : void * @param int|null $month * @param int|null $year */ - private function set(?int $day, ?int $month, ?int $year) : void + private function set(?int $day, ?int $month, ?int $year): void { $this->day = $day; $this->month = $month; @@ -107,7 +107,7 @@ private function set(?int $day, ?int $month, ?int $year) : void /** * @return int|null */ - public function getDay() : ?int + public function getDay(): ?int { return $this->day; } @@ -115,7 +115,7 @@ public function getDay() : ?int /** * @return int|null */ - public function getMonth() : ?int + public function getMonth(): ?int { return $this->month; } @@ -123,7 +123,7 @@ public function getMonth() : ?int /** * @return int|null */ - public function getYear() : ?int + public function getYear(): ?int { return $this->year; } diff --git a/src/Model/Common/MagazineMeta.php b/src/Model/Common/MagazineMeta.php index 68cb0b9c..e0b30797 100644 --- a/src/Model/Common/MagazineMeta.php +++ b/src/Model/Common/MagazineMeta.php @@ -7,6 +7,4 @@ * * @package Jikan\Model\Common */ -class MagazineMeta extends ItemBasicMeta -{ -} +class MagazineMeta extends ItemBasicMeta {} diff --git a/src/Model/Common/MangaCard.php b/src/Model/Common/MangaCard.php index e8dc645a..8a5e4257 100644 --- a/src/Model/Common/MangaCard.php +++ b/src/Model/Common/MangaCard.php @@ -139,7 +139,7 @@ protected static function setProperties(Parser\Common\MangaCardParser $parser, $ */ public function __toString() { - return (string)$this->url; + return (string) $this->url; } /** diff --git a/src/Model/Common/Title.php b/src/Model/Common/Title.php index c1a2820d..26449f32 100644 --- a/src/Model/Common/Title.php +++ b/src/Model/Common/Title.php @@ -10,8 +10,8 @@ */ class Title { - const TYPE_DEFAULT = 'Default'; - const TYPE_SYNONYM = 'Synonym'; + public const TYPE_DEFAULT = 'Default'; + public const TYPE_SYNONYM = 'Synonym'; /** * @var string diff --git a/src/Model/Common/YoutubeMeta.php b/src/Model/Common/YoutubeMeta.php index 5403812b..0634eacf 100644 --- a/src/Model/Common/YoutubeMeta.php +++ b/src/Model/Common/YoutubeMeta.php @@ -36,9 +36,9 @@ class YoutubeMeta * @param string $embedUrl * @return YoutubeMeta */ - public static function factory(?string $embedUrl) : self + public static function factory(?string $embedUrl): self { - $instance = new self; + $instance = new self(); $instance->embedUrl = $embedUrl; $instance->youtubeId = Media::youtubeIdFromUrl($embedUrl); diff --git a/src/Model/Forum/ForumPost.php b/src/Model/Forum/ForumPost.php index fc429d51..ef709f6b 100644 --- a/src/Model/Forum/ForumPost.php +++ b/src/Model/Forum/ForumPost.php @@ -1,6 +1,5 @@ url= $parser->getUrl(); + $instance->url = $parser->getUrl(); $instance->images = UserImageResource::factory($parser->getImageUrl()); $instance->username = $parser->getUsername(); $instance->chaptersRead = $parser->getChaptersRead(); -// $instance->scores = $parser->getMangaScores(); + // $instance->scores = $parser->getMangaScores(); return $instance; } diff --git a/src/Model/Manga/MangaReviews.php b/src/Model/Manga/MangaReviews.php index 1e5ea08f..c17c528f 100644 --- a/src/Model/Manga/MangaReviews.php +++ b/src/Model/Manga/MangaReviews.php @@ -36,7 +36,7 @@ public static function fromParser(Parser\Manga\MangaReviewsParser $parser): self /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Manga/MangaUserUpdates.php b/src/Model/Manga/MangaUserUpdates.php index fd23c84c..0bee1927 100644 --- a/src/Model/Manga/MangaUserUpdates.php +++ b/src/Model/Manga/MangaUserUpdates.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Manga\MangaRecentlyUpdatedByUsersParser return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/News/NewsList.php b/src/Model/News/NewsList.php index 48a0cb50..b5a868bd 100644 --- a/src/Model/News/NewsList.php +++ b/src/Model/News/NewsList.php @@ -41,7 +41,7 @@ public static function fromParser(Parser\News\NewsListParser $parser): self return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Recommendations/RecentRecommendations.php b/src/Model/Recommendations/RecentRecommendations.php index 3ac0150f..80a99f64 100644 --- a/src/Model/Recommendations/RecentRecommendations.php +++ b/src/Model/Recommendations/RecentRecommendations.php @@ -43,7 +43,7 @@ public static function fromParser(Parser\Recommendations\RecentRecommendationsPa /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Recommendations/UserRecommendations.php b/src/Model/Recommendations/UserRecommendations.php index d3ae6595..f3341095 100644 --- a/src/Model/Recommendations/UserRecommendations.php +++ b/src/Model/Recommendations/UserRecommendations.php @@ -41,7 +41,7 @@ public static function fromParser(Parser\Recommendations\UserRecommendationsPars /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Resource/AnimeImageResource/AnimeImageResource.php b/src/Model/Resource/AnimeImageResource/AnimeImageResource.php index 90cec496..b0be253d 100644 --- a/src/Model/Resource/AnimeImageResource/AnimeImageResource.php +++ b/src/Model/Resource/AnimeImageResource/AnimeImageResource.php @@ -22,9 +22,9 @@ class AnimeImageResource * @param string $imageUrl * @return AnimeImageResource */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->jpg = Jpg::factory($imageUrl); $instance->webp = Webp::factory($imageUrl); @@ -35,7 +35,7 @@ public static function factory(?string $imageUrl) : self /** * @return string */ - public function __toString() : string + public function __toString(): string { return $this->getJpg()->getImageUrl(); } diff --git a/src/Model/Resource/AnimeImageResource/Jpg.php b/src/Model/Resource/AnimeImageResource/Jpg.php index 52a193d8..d74e62e4 100644 --- a/src/Model/Resource/AnimeImageResource/Jpg.php +++ b/src/Model/Resource/AnimeImageResource/Jpg.php @@ -28,9 +28,9 @@ class Jpg * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = $imageUrl; diff --git a/src/Model/Resource/AnimeImageResource/Webp.php b/src/Model/Resource/AnimeImageResource/Webp.php index d6b99dfb..5937508e 100644 --- a/src/Model/Resource/AnimeImageResource/Webp.php +++ b/src/Model/Resource/AnimeImageResource/Webp.php @@ -28,9 +28,9 @@ class Webp * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = str_replace('.jpg', '.webp', $imageUrl); diff --git a/src/Model/Resource/CharacterImageResource/CharacterImageResource.php b/src/Model/Resource/CharacterImageResource/CharacterImageResource.php index 22c440ad..e85d3bd8 100644 --- a/src/Model/Resource/CharacterImageResource/CharacterImageResource.php +++ b/src/Model/Resource/CharacterImageResource/CharacterImageResource.php @@ -23,9 +23,9 @@ class CharacterImageResource * @param string $imageUrl * @return CharacterImageResource */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->jpg = Jpg::factory($imageUrl); $instance->webp = Webp::factory($imageUrl); @@ -36,7 +36,7 @@ public static function factory(?string $imageUrl) : self /** * @return string */ - public function __toString() : string + public function __toString(): string { return $this->getJpg()->getImageUrl(); } diff --git a/src/Model/Resource/CharacterImageResource/Jpg.php b/src/Model/Resource/CharacterImageResource/Jpg.php index f8f5de25..f24c8537 100644 --- a/src/Model/Resource/CharacterImageResource/Jpg.php +++ b/src/Model/Resource/CharacterImageResource/Jpg.php @@ -17,9 +17,9 @@ class Jpg * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = $imageUrl; diff --git a/src/Model/Resource/CharacterImageResource/Webp.php b/src/Model/Resource/CharacterImageResource/Webp.php index 2163b763..a3b1e0eb 100644 --- a/src/Model/Resource/CharacterImageResource/Webp.php +++ b/src/Model/Resource/CharacterImageResource/Webp.php @@ -22,9 +22,9 @@ class Webp * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = str_replace('.jpg', '.webp', $imageUrl); diff --git a/src/Model/Resource/ClubImageResource/ClubImageResource.php b/src/Model/Resource/ClubImageResource/ClubImageResource.php index 56acce18..f9865bae 100644 --- a/src/Model/Resource/ClubImageResource/ClubImageResource.php +++ b/src/Model/Resource/ClubImageResource/ClubImageResource.php @@ -17,9 +17,9 @@ class ClubImageResource * @param string $imageUrl * @return ClubImageResource */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->jpg = Jpg::factory($imageUrl); @@ -29,7 +29,7 @@ public static function factory(?string $imageUrl) : self /** * @return string */ - public function __toString() : string + public function __toString(): string { return $this->getJpg()->getImageUrl(); } diff --git a/src/Model/Resource/ClubImageResource/Jpg.php b/src/Model/Resource/ClubImageResource/Jpg.php index a3d5c877..10d9ab79 100644 --- a/src/Model/Resource/ClubImageResource/Jpg.php +++ b/src/Model/Resource/ClubImageResource/Jpg.php @@ -17,9 +17,9 @@ class Jpg * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = $imageUrl; diff --git a/src/Model/Resource/CommonImageResource/CommonImageResource.php b/src/Model/Resource/CommonImageResource/CommonImageResource.php index 42c068ae..4bfcaa97 100644 --- a/src/Model/Resource/CommonImageResource/CommonImageResource.php +++ b/src/Model/Resource/CommonImageResource/CommonImageResource.php @@ -22,9 +22,9 @@ class CommonImageResource * @param string $imageUrl * @return CommonImageResource */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->jpg = Jpg::factory($imageUrl); $instance->webp = Webp::factory($imageUrl); @@ -35,7 +35,7 @@ public static function factory(?string $imageUrl) : self /** * @return string */ - public function __toString() : string + public function __toString(): string { return $this->getJpg()->getImageUrl(); } diff --git a/src/Model/Resource/CommonImageResource/Jpg.php b/src/Model/Resource/CommonImageResource/Jpg.php index 69944061..250ad50c 100644 --- a/src/Model/Resource/CommonImageResource/Jpg.php +++ b/src/Model/Resource/CommonImageResource/Jpg.php @@ -28,9 +28,9 @@ class Jpg * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = $imageUrl; diff --git a/src/Model/Resource/CommonImageResource/Webp.php b/src/Model/Resource/CommonImageResource/Webp.php index 739a95bc..21420bb4 100644 --- a/src/Model/Resource/CommonImageResource/Webp.php +++ b/src/Model/Resource/CommonImageResource/Webp.php @@ -28,9 +28,9 @@ class Webp * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = str_replace('.jpg', '.webp', $imageUrl); diff --git a/src/Model/Resource/PersonImageResource/Jpg.php b/src/Model/Resource/PersonImageResource/Jpg.php index a7305c4d..7bed13fd 100644 --- a/src/Model/Resource/PersonImageResource/Jpg.php +++ b/src/Model/Resource/PersonImageResource/Jpg.php @@ -17,9 +17,9 @@ class Jpg * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = $imageUrl; @@ -33,7 +33,7 @@ public static function factory(?string $imageUrl) : self /** * @return string */ - public function __toString() : string + public function __toString(): string { return $this->getJpg()->getImageUrl(); } diff --git a/src/Model/Resource/PersonImageResource/PersonImageResource.php b/src/Model/Resource/PersonImageResource/PersonImageResource.php index 5edc5124..977b0b4c 100644 --- a/src/Model/Resource/PersonImageResource/PersonImageResource.php +++ b/src/Model/Resource/PersonImageResource/PersonImageResource.php @@ -18,9 +18,9 @@ class PersonImageResource * @param string $imageUrl * @return PersonImageResource */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->jpg = Jpg::factory($imageUrl); diff --git a/src/Model/Resource/UserImageResource/Jpg.php b/src/Model/Resource/UserImageResource/Jpg.php index be47e0aa..353fb93f 100644 --- a/src/Model/Resource/UserImageResource/Jpg.php +++ b/src/Model/Resource/UserImageResource/Jpg.php @@ -17,9 +17,9 @@ class Jpg * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = $imageUrl; @@ -29,7 +29,7 @@ public static function factory(?string $imageUrl) : self /** * @return string */ - public function __toString() : string + public function __toString(): string { return $this->getJpg()->getImageUrl(); } diff --git a/src/Model/Resource/UserImageResource/UserImageResource.php b/src/Model/Resource/UserImageResource/UserImageResource.php index beca6ab4..be4a1576 100644 --- a/src/Model/Resource/UserImageResource/UserImageResource.php +++ b/src/Model/Resource/UserImageResource/UserImageResource.php @@ -22,9 +22,9 @@ class UserImageResource * @param string $imageUrl * @return UserImageResource */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->jpg = Jpg::factory($imageUrl); $instance->webp = Webp::factory($imageUrl); diff --git a/src/Model/Resource/UserImageResource/Webp.php b/src/Model/Resource/UserImageResource/Webp.php index dc99c731..0ed36aab 100644 --- a/src/Model/Resource/UserImageResource/Webp.php +++ b/src/Model/Resource/UserImageResource/Webp.php @@ -17,9 +17,9 @@ class Webp * @param string $imageUrl * @return \Jikan\Model\Resource\AnimeImageResource\Webp */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = str_replace('.jpg', '.webp', $imageUrl); diff --git a/src/Model/Resource/WrapImageResource/Jpg.php b/src/Model/Resource/WrapImageResource/Jpg.php index 207f154d..8e69db2a 100644 --- a/src/Model/Resource/WrapImageResource/Jpg.php +++ b/src/Model/Resource/WrapImageResource/Jpg.php @@ -17,9 +17,9 @@ class Jpg * @param string $imageUrl * @return Jpg */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->imageUrl = $imageUrl; diff --git a/src/Model/Resource/WrapImageResource/WrapImageResource.php b/src/Model/Resource/WrapImageResource/WrapImageResource.php index 60967b58..0f1acf4f 100644 --- a/src/Model/Resource/WrapImageResource/WrapImageResource.php +++ b/src/Model/Resource/WrapImageResource/WrapImageResource.php @@ -17,9 +17,9 @@ class WrapImageResource * @param string $imageUrl * @return WrapImageResource */ - public static function factory(?string $imageUrl) : self + public static function factory(?string $imageUrl): self { - $instance = new self; + $instance = new self(); $instance->jpg = Jpg::factory($imageUrl); @@ -29,7 +29,7 @@ public static function factory(?string $imageUrl) : self /** * @return string */ - public function __toString() : string + public function __toString(): string { return $this->getJpg()->getImageUrl(); } diff --git a/src/Model/Resource/YoutubeImageResource.php b/src/Model/Resource/YoutubeImageResource.php index d208a463..12c0b31e 100644 --- a/src/Model/Resource/YoutubeImageResource.php +++ b/src/Model/Resource/YoutubeImageResource.php @@ -38,9 +38,9 @@ class YoutubeImageResource * @param string $id * @return YoutubeImageResource */ - public static function factory(?string $id) : self + public static function factory(?string $id): self { - $instance = new self; + $instance = new self(); if ($id !== null) { $instance->imageUrl = sprintf('https://img.youtube.com/vi/%s/default.jpg', $id); diff --git a/src/Model/Reviews/Reviews.php b/src/Model/Reviews/Reviews.php index c19bb175..96843a55 100644 --- a/src/Model/Reviews/Reviews.php +++ b/src/Model/Reviews/Reviews.php @@ -45,7 +45,7 @@ public static function fromParser(Parser\Reviews\ReviewsParser $parser): self /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Search/AnimeSearch.php b/src/Model/Search/AnimeSearch.php index c04f0621..60387ae2 100644 --- a/src/Model/Search/AnimeSearch.php +++ b/src/Model/Search/AnimeSearch.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Search\AnimeSearchParser $parser): self return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Search/CharacterSearch.php b/src/Model/Search/CharacterSearch.php index 7bd85c88..9a47f7f9 100644 --- a/src/Model/Search/CharacterSearch.php +++ b/src/Model/Search/CharacterSearch.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Search\CharacterSearchParser $parser): return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Search/PersonSearch.php b/src/Model/Search/PersonSearch.php index 1690b40b..210d4d3b 100644 --- a/src/Model/Search/PersonSearch.php +++ b/src/Model/Search/PersonSearch.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Search\PersonSearchParser $parser): sel return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Search/UserSearch.php b/src/Model/Search/UserSearch.php index 8ac027a4..05db89a2 100644 --- a/src/Model/Search/UserSearch.php +++ b/src/Model/Search/UserSearch.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Search\UserSearchParser $parser): self return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Top/TopAnime.php b/src/Model/Top/TopAnime.php index 639125f3..d8f4476b 100644 --- a/src/Model/Top/TopAnime.php +++ b/src/Model/Top/TopAnime.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Top\TopAnimeParser $parser): self return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Top/TopCharacters.php b/src/Model/Top/TopCharacters.php index f69f0cd8..970c200e 100644 --- a/src/Model/Top/TopCharacters.php +++ b/src/Model/Top/TopCharacters.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Top\TopCharactersParser $parser): self /** * @return TopCharacters */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Top/TopManga.php b/src/Model/Top/TopManga.php index ba91388e..a3f19367 100644 --- a/src/Model/Top/TopManga.php +++ b/src/Model/Top/TopManga.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Top\TopMangaParser $parser): self return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/Top/TopPeople.php b/src/Model/Top/TopPeople.php index 64377d0e..5cb7f072 100644 --- a/src/Model/Top/TopPeople.php +++ b/src/Model/Top/TopPeople.php @@ -42,7 +42,7 @@ public static function fromParser(Parser\Top\TopPeopleParser $parser): self return $instance; } - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/Model/User/FavoriteAnime.php b/src/Model/User/FavoriteAnime.php index 70eaa9d9..d8a9d29c 100644 --- a/src/Model/User/FavoriteAnime.php +++ b/src/Model/User/FavoriteAnime.php @@ -1,6 +1,5 @@ readStartDate = Parser::parseDateMDY($item->start_date_string); $instance->readEndDate = Parser::parseDateMDY($item->finish_date_string); $instance->days = $item->days_string; - $instance->retail= empty($item->retail_string) ? null : $item->retail_string; + $instance->retail = empty($item->retail_string) ? null : $item->retail_string; $instance->priority = $item->priority_string; $instance->addedToList = $item->is_added_to_list; diff --git a/src/Model/User/Reviews/UserReviews.php b/src/Model/User/Reviews/UserReviews.php index 0e785975..da1a4a9b 100644 --- a/src/Model/User/Reviews/UserReviews.php +++ b/src/Model/User/Reviews/UserReviews.php @@ -40,7 +40,7 @@ public static function fromParser(UserReviewsParser $parser): UserReviews /** * @return static */ - public static function mock() : self + public static function mock(): self { return new self(); } diff --git a/src/MyAnimeList/MalClient.php b/src/MyAnimeList/MalClient.php index 42f31762..d80abe2c 100644 --- a/src/MyAnimeList/MalClient.php +++ b/src/MyAnimeList/MalClient.php @@ -1,9 +1,9 @@ httpClient = $httpClient ?? HttpClient::create(); - $this->ghoutte = new GoutteWrapper($this->httpClient); + $this->httpClientWrapper = new HttpClientWrapper($this->httpClient); } /** @@ -56,7 +56,7 @@ public function __construct(HttpClientInterface $httpClient = null) */ public function getAnime(Request\Anime\AnimeRequest $request): Model\Anime\Anime { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\AnimeParser($crawler); @@ -76,7 +76,7 @@ public function getAnimeEpisodes(Request\Anime\AnimeEpisodesRequest $request): M { // Episode page returns 404 when there are no results try { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); } catch (\Exception $e) { if ($e->getCode() === 404) { return new Model\Anime\Episodes(); @@ -102,7 +102,7 @@ public function getAnimeEpisodes(Request\Anime\AnimeEpisodesRequest $request): M */ public function getAnimeVideos(Request\Anime\AnimeVideosRequest $request): Model\Anime\AnimeVideos { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\VideosParser($crawler); @@ -120,7 +120,7 @@ public function getAnimeVideos(Request\Anime\AnimeVideosRequest $request): Model */ public function getAnimeVideosEpisodes(Request\Anime\AnimeVideosEpisodesRequest $request): Model\Anime\AnimeVideosEpisodes { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\VideosParser($crawler); @@ -138,7 +138,7 @@ public function getAnimeVideosEpisodes(Request\Anime\AnimeVideosEpisodesRequest */ public function getManga(Request\Manga\MangaRequest $request): Model\Manga\Manga { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Manga\MangaParser($crawler); @@ -161,7 +161,7 @@ public function getCharacter(Request\Character\CharacterRequest $request): Model throw new BadResponseException(sprintf('404 on %s', $request->getPath()), 404); } - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); // MAL returns `Invalid ID provided.` instead of 404 on invalid characters $badResult = $crawler->filterXPath('//*[@id="content"]/div[@class="badresult"]'); @@ -191,7 +191,7 @@ public function getPerson(Request\Person\PersonRequest $request): Model\Person\P throw new BadResponseException(sprintf('404 on %s', $request->getPath()), 404); } - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Person\PersonParser($crawler); @@ -209,7 +209,7 @@ public function getPerson(Request\Person\PersonRequest $request): Model\Person\P */ public function getUserProfile(Request\User\UserProfileRequest $request): Model\User\Profile { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\User\Profile\UserProfileParser($crawler); @@ -227,7 +227,7 @@ public function getUserProfile(Request\User\UserProfileRequest $request): Model\ */ public function getUserFriends(Request\User\UserFriendsRequest $request): Model\User\Friends { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\User\Friends\FriendsParser($crawler); @@ -245,7 +245,7 @@ public function getUserFriends(Request\User\UserFriendsRequest $request): Model\ */ public function getSeasonal(Request\Seasonal\SeasonalRequest $request): Model\Seasonal\Seasonal { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Seasonal\SeasonalParser($crawler); @@ -263,7 +263,7 @@ public function getSeasonal(Request\Seasonal\SeasonalRequest $request): Model\Se */ public function getProducer(Request\Producer\ProducerRequest $request): Model\Producer\Producer { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Producer\ProducerParser($crawler); @@ -281,7 +281,7 @@ public function getProducer(Request\Producer\ProducerRequest $request): Model\Pr */ public function getMagazine(Request\Magazine\MagazineRequest $request): Model\Magazine\Magazine { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Magazine\MagazineParser($crawler); @@ -299,7 +299,7 @@ public function getMagazine(Request\Magazine\MagazineRequest $request): Model\Ma */ public function getAnimeGenre(Request\Genre\AnimeGenreRequest $request): Model\Genre\AnimeGenre { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Genre\AnimeGenreParser($crawler); @@ -317,7 +317,7 @@ public function getAnimeGenre(Request\Genre\AnimeGenreRequest $request): Model\G */ public function getMangaGenre(Request\Genre\MangaGenreRequest $request): Model\Genre\MangaGenre { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Genre\MangaGenreParser($crawler); @@ -335,7 +335,7 @@ public function getMangaGenre(Request\Genre\MangaGenreRequest $request): Model\G */ public function getSchedule(Request\Schedule\ScheduleRequest $request): Model\Schedule\Schedule { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Schedule\ScheduleParser($crawler); @@ -354,7 +354,7 @@ public function getSchedule(Request\Schedule\ScheduleRequest $request): Model\Sc public function getAnimeCharactersAndStaff( Request\Anime\AnimeCharactersAndStaffRequest $request ): Model\Anime\AnimeCharactersAndStaff { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\CharactersAndStaffParser($crawler); @@ -372,7 +372,7 @@ public function getAnimeCharactersAndStaff( */ public function getAnimePictures(Request\Anime\AnimePicturesRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Common\PicturesPageParser($crawler); @@ -390,7 +390,7 @@ public function getAnimePictures(Request\Anime\AnimePicturesRequest $request): a */ public function getMangaPictures(Request\Manga\MangaPicturesRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Common\PicturesPageParser($crawler); @@ -408,7 +408,7 @@ public function getMangaPictures(Request\Manga\MangaPicturesRequest $request): a */ public function getCharacterPictures(Request\Character\CharacterPicturesRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Common\DefaultPicturesPageParser($crawler); @@ -427,7 +427,7 @@ public function getCharacterPictures(Request\Character\CharacterPicturesRequest */ public function getPersonPictures(Request\Person\PersonPicturesRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Common\DefaultPicturesPageParser($crawler); @@ -446,7 +446,7 @@ public function getPersonPictures(Request\Person\PersonPicturesRequest $request) */ public function getNewsList(Request\RequestInterface $request): Model\News\NewsList { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\News\NewsListParser($crawler); @@ -465,11 +465,11 @@ public function getNewsList(Request\RequestInterface $request): Model\News\NewsL */ public function getAnimeSearch(Request\Search\AnimeSearchRequest $request): Model\Search\AnimeSearch { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); -// if ($this->ghoutte->getInternalResponse()->getStatusCode()) { -// return Model\Search\AnimeSearch::mock(); -// } + // if ($this->httpClientWrapper->getInternalResponse()->getStatusCode()) { + // return Model\Search\AnimeSearch::mock(); + // } try { $parser = new Parser\Search\AnimeSearchParser($crawler); @@ -489,7 +489,7 @@ public function getAnimeSearch(Request\Search\AnimeSearchRequest $request): Mode */ public function getAnimeSearchAlt(Request\Search\AnimeSearchRequest $request): Model\Search\AnimeSearchAlt { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Search\AnimeSearchParser($crawler); @@ -508,7 +508,7 @@ public function getAnimeSearchAlt(Request\Search\AnimeSearchRequest $request): M */ public function getMangaSearch(Request\Search\MangaSearchRequest $request): Model\Search\MangaSearch { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Search\MangaSearchParser($crawler); @@ -528,7 +528,7 @@ public function getMangaSearch(Request\Search\MangaSearchRequest $request): Mode public function getCharacterSearch(Request\Search\CharacterSearchRequest $request): Model\Search\CharacterSearch { try { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); } catch (BadResponseException $e) { if ($e->getCode() === 404) { return Model\Search\CharacterSearch::mock(); @@ -553,7 +553,7 @@ public function getCharacterSearch(Request\Search\CharacterSearchRequest $reques public function getPersonSearch(Request\Search\PersonSearchRequest $request): Model\Search\PersonSearch { try { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); } catch (BadResponseException $e) { if ($e->getCode() === 404) { return Model\Search\PersonSearch::mock(); @@ -578,7 +578,7 @@ public function getPersonSearch(Request\Search\PersonSearchRequest $request): Mo */ public function getMangaCharacters(Request\Manga\MangaCharactersRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Manga\CharactersParser($crawler); @@ -597,7 +597,7 @@ public function getMangaCharacters(Request\Manga\MangaCharactersRequest $request */ public function getTopAnime(Request\Top\TopAnimeRequest $request): Model\Top\TopAnime { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Top\TopAnimeParser($crawler); @@ -616,7 +616,7 @@ public function getTopAnime(Request\Top\TopAnimeRequest $request): Model\Top\Top */ public function getTopManga(Request\Top\TopMangaRequest $request): Model\Top\TopManga { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Top\TopMangaParser($crawler); @@ -635,7 +635,7 @@ public function getTopManga(Request\Top\TopMangaRequest $request): Model\Top\Top */ public function getTopCharacters(Request\Top\TopCharactersRequest $request): Model\Top\TopCharacters { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Top\TopCharactersParser($crawler); @@ -654,7 +654,7 @@ public function getTopCharacters(Request\Top\TopCharactersRequest $request): Mod */ public function getTopPeople(Request\Top\TopPeopleRequest $request): Model\Top\TopPeople { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Top\TopPeopleParser($crawler); @@ -673,7 +673,7 @@ public function getTopPeople(Request\Top\TopPeopleRequest $request): Model\Top\T */ public function getAnimeStats(Request\Anime\AnimeStatsRequest $request): Model\Anime\AnimeStats { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\AnimeStatsParser($crawler); @@ -691,7 +691,7 @@ public function getAnimeStats(Request\Anime\AnimeStatsRequest $request): Model\A */ public function getMangaStats(Request\Manga\MangaStatsRequest $request): Model\Manga\MangaStats { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Manga\MangaStatsParser($crawler); @@ -709,7 +709,7 @@ public function getMangaStats(Request\Manga\MangaStatsRequest $request): Model\M */ public function getAnimeForum(Request\Anime\AnimeForumRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Forum\ForumPageParser($crawler); @@ -727,7 +727,7 @@ public function getAnimeForum(Request\Anime\AnimeForumRequest $request): array */ public function getMangaForum(Request\Manga\MangaForumRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Forum\ForumPageParser($crawler); @@ -745,7 +745,7 @@ public function getMangaForum(Request\Manga\MangaForumRequest $request): array */ public function getAnimeMoreInfo(Request\Anime\AnimeMoreInfoRequest $request): ?string { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\MoreInfoParser($crawler); @@ -763,7 +763,7 @@ public function getAnimeMoreInfo(Request\Anime\AnimeMoreInfoRequest $request): ? */ public function getMangaMoreInfo(Request\Manga\MangaMoreInfoRequest $request): ?string { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Manga\MoreInfoParser($crawler); @@ -781,7 +781,7 @@ public function getMangaMoreInfo(Request\Manga\MangaMoreInfoRequest $request): ? */ public function getSeasonList(Request\SeasonList\SeasonListRequest $request): Model\SeasonList\SeasonArchive { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\SeasonList\SeasonListParser($crawler); @@ -799,7 +799,7 @@ public function getSeasonList(Request\SeasonList\SeasonListRequest $request): Mo */ public function getUserHistory(Request\User\UserHistoryRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\User\History\HistoryParser($crawler); @@ -822,7 +822,7 @@ public function getUserAnimeList(Request\User\UserAnimeListRequest $request): ar if ($response->getStatusCode() >= 400) { throw new BadResponseException( - $response->getStatusCode().' on '.$response->getInfo('url'), + $response->getStatusCode() . ' on ' . $response->getInfo('url'), $response->getStatusCode() ); } @@ -836,7 +836,7 @@ public function getUserAnimeList(Request\User\UserAnimeListRequest $request): ar return $model; } catch (\Exception $e) { throw new BadResponseException( - $e->getCode().' on '.$request->getPath(), + $e->getCode() . ' on ' . $request->getPath(), $e->getCode() ); } @@ -856,7 +856,7 @@ public function getUserMangaList(Request\User\UserMangaListRequest $request): ar if ($response->getStatusCode() >= 400) { throw new BadResponseException( - $response->getStatusCode().' on '.$response->getInfo('url'), + $response->getStatusCode() . ' on ' . $response->getInfo('url'), $response->getStatusCode() ); } @@ -870,7 +870,7 @@ public function getUserMangaList(Request\User\UserMangaListRequest $request): ar return $model; } catch (\Exception $e) { throw new BadResponseException( - $e->getCode().' on '.$request->getPath(), + $e->getCode() . ' on ' . $request->getPath(), $e->getCode() ); } @@ -885,7 +885,7 @@ public function getUserMangaList(Request\User\UserMangaListRequest $request): ar */ public function getAnimeRecentlyUpdatedByUsers(Request\Anime\AnimeRecentlyUpdatedByUsersRequest $request): Model\Anime\AnimeUserUpdates { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\AnimeRecentlyUpdatedByUsersParser($crawler); @@ -903,7 +903,7 @@ public function getAnimeRecentlyUpdatedByUsers(Request\Anime\AnimeRecentlyUpdate */ public function getMangaRecentlyUpdatedByUsers(Request\Manga\MangaRecentlyUpdatedByUsersRequest $request): Model\Manga\MangaUserUpdates { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Manga\MangaRecentlyUpdatedByUsersParser($crawler); @@ -921,7 +921,7 @@ public function getMangaRecentlyUpdatedByUsers(Request\Manga\MangaRecentlyUpdate */ public function getAnimeRecommendations(Request\Anime\AnimeRecommendationsRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Common\Recommendations($crawler); @@ -939,7 +939,7 @@ public function getAnimeRecommendations(Request\Anime\AnimeRecommendationsReques */ public function getMangaRecommendations(Request\Manga\MangaRecommendationsRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Common\Recommendations($crawler); @@ -959,7 +959,7 @@ public function getMangaRecommendations(Request\Manga\MangaRecommendationsReques */ public function getClubUsers(Request\Club\UserListRequest $request): Model\Club\UserList { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Club\UserListParser($crawler); @@ -979,7 +979,7 @@ public function getClubUsers(Request\Club\UserListRequest $request): Model\Club\ */ public function getAnimeReviews(Request\Anime\AnimeReviewsRequest $request): Model\Anime\AnimeReviews { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\AnimeReviewsParser($crawler); @@ -998,7 +998,7 @@ public function getAnimeReviews(Request\Anime\AnimeReviewsRequest $request): Mod */ public function getMangaReviews(Request\Manga\MangaReviewsRequest $request): Model\Manga\MangaReviews { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Manga\MangaReviewsParser($crawler); @@ -1017,7 +1017,7 @@ public function getMangaReviews(Request\Manga\MangaReviewsRequest $request): Mod */ public function getClub(Request\Club\ClubRequest $request): Model\Club\Club { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Club\ClubParser($crawler); @@ -1036,7 +1036,7 @@ public function getClub(Request\Club\ClubRequest $request): Model\Club\Club */ public function getAnimeEpisode(Request\Anime\AnimeEpisodeRequest $request): Model\Anime\AnimeEpisode { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Anime\AnimeEpisodeParser($crawler); @@ -1055,7 +1055,7 @@ public function getAnimeEpisode(Request\Anime\AnimeEpisodeRequest $request): Mod */ public function getProducers(Request\Producer\ProducersRequest $request): Model\Producer\ProducerList { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Producer\ProducerListParser($crawler); @@ -1074,7 +1074,7 @@ public function getProducers(Request\Producer\ProducersRequest $request): Model\ */ public function getMagazines(Request\Magazine\MagazinesRequest $request): Model\Magazine\MagazineList { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Magazine\MagazineListParser($crawler); @@ -1093,7 +1093,7 @@ public function getMagazines(Request\Magazine\MagazinesRequest $request): Model\ */ public function getAnimeGenres(Request\Genre\AnimeGenresRequest $request): Model\Genre\AnimeGenreList { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Genre\AnimeGenreListParser($crawler); @@ -1112,7 +1112,7 @@ public function getAnimeGenres(Request\Genre\AnimeGenresRequest $request): Model */ public function getMangaGenres(Request\Genre\MangaGenresRequest $request): Model\Genre\MangaGenreList { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Genre\MangaGenreListParser($crawler); @@ -1132,7 +1132,7 @@ public function getMangaGenres(Request\Genre\MangaGenresRequest $request): Model */ public function getReviews(Request\Reviews\ReviewsRequest $request): Model\Reviews\Reviews { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Reviews\ReviewsParser($crawler); @@ -1150,7 +1150,7 @@ public function getReviews(Request\Reviews\ReviewsRequest $request): Model\Revie */ public function getRecentRecommendations(Request\Recommendations\RecentRecommendationsRequest $request): Model\Recommendations\RecentRecommendations { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Recommendations\RecentRecommendationsParser($crawler); @@ -1171,7 +1171,7 @@ public function getUserSearch(Request\Search\UserSearchRequest $request): Model\ { // Returns 404 when there are no results try { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); } catch (\Exception $e) { if ($e->getCode() === 404) { return new Model\Search\UserSearch(); @@ -1196,7 +1196,7 @@ public function getUserSearch(Request\Search\UserSearchRequest $request): Model\ */ public function getRecentOnlineUsers(Request\User\RecentlyOnlineUsersRequest $request): array { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Search\UserSearchParser($crawler); @@ -1212,9 +1212,9 @@ public function getRecentOnlineUsers(Request\User\RecentlyOnlineUsersRequest $re * @throws BadResponseException * @throws ParserException */ - public function getUsernameById(Request\User\UsernameByIdRequest $request) : Model\Common\UserMetaBasic + public function getUsernameById(Request\User\UsernameByIdRequest $request): Model\Common\UserMetaBasic { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\User\UsernameByIdParser($crawler); @@ -1230,10 +1230,10 @@ public function getUsernameById(Request\User\UsernameByIdRequest $request) : Mod * @throws BadResponseException * @throws ParserException */ - public function getUserReviews(Request\User\UserReviewsRequest $request) : Model\User\Reviews\UserReviews + public function getUserReviews(Request\User\UserReviewsRequest $request): Model\User\Reviews\UserReviews { try { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); } catch (\Exception $e) { if ($e->getCode() === 404) { return Model\User\Reviews\UserReviews::mock(); @@ -1254,9 +1254,9 @@ public function getUserReviews(Request\User\UserReviewsRequest $request) : Model * @throws BadResponseException * @throws ParserException */ - public function getRecentEpisodes(Request\Watch\RecentEpisodesRequest $request) : Model\Watch\Episodes + public function getRecentEpisodes(Request\Watch\RecentEpisodesRequest $request): Model\Watch\Episodes { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Watch\WatchEpisodesParser($crawler); @@ -1272,9 +1272,9 @@ public function getRecentEpisodes(Request\Watch\RecentEpisodesRequest $request) * @throws BadResponseException * @throws ParserException */ - public function getPopularEpisodes(Request\Watch\PopularEpisodesRequest $request) : Model\Watch\Episodes + public function getPopularEpisodes(Request\Watch\PopularEpisodesRequest $request): Model\Watch\Episodes { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Watch\WatchEpisodesParser($crawler); @@ -1292,8 +1292,8 @@ public function getPopularEpisodes(Request\Watch\PopularEpisodesRequest $request */ public function getRecentPromotionalVideos( Request\Watch\RecentPromotionalVideosRequest $request - ) : Model\Watch\PromotionalVideos { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + ): Model\Watch\PromotionalVideos { + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Watch\WatchPromotionalVideosParser($crawler); @@ -1311,8 +1311,8 @@ public function getRecentPromotionalVideos( */ public function getPopularPromotionalVideos( Request\Watch\PopularPromotionalVideosRequest $request - ) : Model\Watch\PromotionalVideos { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + ): Model\Watch\PromotionalVideos { + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Watch\WatchPromotionalVideosParser($crawler); @@ -1331,7 +1331,7 @@ public function getPopularPromotionalVideos( */ public function getUserRecommendations(Request\User\UserRecommendationsRequest $request): Model\Recommendations\UserRecommendations { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); try { $parser = new Parser\Recommendations\UserRecommendationsParser($crawler); @@ -1347,11 +1347,11 @@ public function getUserRecommendations(Request\User\UserRecommendationsRequest $ * @throws BadResponseException * @throws ParserException */ - public function getUserClubs(Request\User\UserClubsRequest $request) : array + public function getUserClubs(Request\User\UserClubsRequest $request): array { // user clubs page returns 404 when there are none added try { - $crawler = $this->ghoutte->request('GET', $request->getPath()); + $crawler = $this->httpClientWrapper->request('GET', $request->getPath()); } catch (\Exception $e) { if ($e->getCode() === 404) { return []; diff --git a/src/Parser/Anime/AnimeParser.php b/src/Parser/Anime/AnimeParser.php index 4d0f7580..8a8d6e23 100644 --- a/src/Parser/Anime/AnimeParser.php +++ b/src/Parser/Anime/AnimeParser.php @@ -230,7 +230,7 @@ public function getEpisodes(): ?int ? null : - (int)str_replace( + (int) str_replace( $episodes->text(), '', $episodes->ancestors()->text() diff --git a/src/Parser/Anime/AnimeRecentlyUpdatedByUsersListParser.php b/src/Parser/Anime/AnimeRecentlyUpdatedByUsersListParser.php index e2d0e4a0..076b894c 100644 --- a/src/Parser/Anime/AnimeRecentlyUpdatedByUsersListParser.php +++ b/src/Parser/Anime/AnimeRecentlyUpdatedByUsersListParser.php @@ -151,7 +151,7 @@ public function getModel(): AnimeRecentlyUpdatedByUser return AnimeRecentlyUpdatedByUser::fromParser($this); } - public function getUserMeta() : UserMeta + public function getUserMeta(): UserMeta { return new UserMeta( $this->getUsername(), diff --git a/src/Parser/Anime/AnimeRecentlyUpdatedByUsersParser.php b/src/Parser/Anime/AnimeRecentlyUpdatedByUsersParser.php index 5f6ee973..fafe3dc7 100644 --- a/src/Parser/Anime/AnimeRecentlyUpdatedByUsersParser.php +++ b/src/Parser/Anime/AnimeRecentlyUpdatedByUsersParser.php @@ -49,12 +49,12 @@ function ($c) { } // @todo anime user updates pagination - public function getHasNextPage() : bool + public function getHasNextPage(): bool { return false; } - public function getLastPage() : int + public function getLastPage(): int { return 1; } diff --git a/src/Parser/Anime/AnimeReviewsParser.php b/src/Parser/Anime/AnimeReviewsParser.php index 483344de..58e964c7 100644 --- a/src/Parser/Anime/AnimeReviewsParser.php +++ b/src/Parser/Anime/AnimeReviewsParser.php @@ -32,7 +32,7 @@ public function __construct(Crawler $crawler) /** * @return AnimeReviews */ - public function getModel() : AnimeReviews + public function getModel(): AnimeReviews { return AnimeReviews::fromParser($this); } diff --git a/src/Parser/Anime/AnimeStatsParser.php b/src/Parser/Anime/AnimeStatsParser.php index 8c662472..a427d6cf 100644 --- a/src/Parser/Anime/AnimeStatsParser.php +++ b/src/Parser/Anime/AnimeStatsParser.php @@ -56,7 +56,7 @@ public function getWatching(): int */ private function sanitize($input): int { - return (int)preg_replace('/\D/', '', $input); + return (int) preg_replace('/\D/', '', $input); } /** @@ -187,7 +187,7 @@ function (Crawler $crawler) use (&$scores) { } ); - for ($i=1; $i<=10; $i++) { + for ($i = 1; $i <= 10; $i++) { if (!array_key_exists($i, $scores)) { $scores[$i] = AnimeStatsScore::setProperties($i, 0, 0); } diff --git a/src/Parser/Anime/CharactersAndStaffParser.php b/src/Parser/Anime/CharactersAndStaffParser.php index 82588322..7acc8390 100644 --- a/src/Parser/Anime/CharactersAndStaffParser.php +++ b/src/Parser/Anime/CharactersAndStaffParser.php @@ -68,7 +68,7 @@ public function getStaff(): array ->ancestors()->nextAll() ->reduce( function (Crawler $crawler) { - return (bool)$crawler->filterXPath( + return (bool) $crawler->filterXPath( '//a[contains(@href, "https://myanimelist.net/people")]' )->count(); } diff --git a/src/Parser/Anime/EpisodeListItemParser.php b/src/Parser/Anime/EpisodeListItemParser.php index cea065db..348ec8fb 100644 --- a/src/Parser/Anime/EpisodeListItemParser.php +++ b/src/Parser/Anime/EpisodeListItemParser.php @@ -46,7 +46,7 @@ public function getModel(): EpisodeListItem */ public function getEpisodeId(): int { - return (int)$this->crawler->filterXPath('//td[contains(@class, \'episode-number\')]')->text(); + return (int) $this->crawler->filterXPath('//td[contains(@class, \'episode-number\')]')->text(); } /** diff --git a/src/Parser/Anime/EpisodesParser.php b/src/Parser/Anime/EpisodesParser.php index ff56f4cf..5818ccc3 100644 --- a/src/Parser/Anime/EpisodesParser.php +++ b/src/Parser/Anime/EpisodesParser.php @@ -71,7 +71,7 @@ public function getLastPage(): int preg_match('~\?offset=(\d+)$~', $pages->attr('href'), $page); - return ((int) $page[1]/100) + 1; + return ((int) $page[1] / 100) + 1; } /** diff --git a/src/Parser/Anime/StaffListItemParser.php b/src/Parser/Anime/StaffListItemParser.php index 79c9ebbd..ef96f4ab 100644 --- a/src/Parser/Anime/StaffListItemParser.php +++ b/src/Parser/Anime/StaffListItemParser.php @@ -1,6 +1,5 @@ getUrl(), $matches); diff --git a/src/Parser/Character/CharacterParser.php b/src/Parser/Character/CharacterParser.php index 3a903b2b..536c199d 100644 --- a/src/Parser/Character/CharacterParser.php +++ b/src/Parser/Character/CharacterParser.php @@ -138,7 +138,7 @@ public function getMemberFavorites(): int $crawler = $this->crawler->filterXPath('//*[@id="content"]/table/tr/td[1]'); $crawler = Parser::removeChildNodes($crawler); - return (int)preg_replace('/\D/', '', $crawler->text()); + return (int) preg_replace('/\D/', '', $crawler->text()); } /** diff --git a/src/Parser/Character/OgraphyParser.php b/src/Parser/Character/OgraphyParser.php index 53a5d9c8..f3579887 100644 --- a/src/Parser/Character/OgraphyParser.php +++ b/src/Parser/Character/OgraphyParser.php @@ -33,7 +33,7 @@ public function __construct(Crawler $crawler) */ public function getMalId(): int { - return (int)preg_replace('#https://myanimelist.net/\w+/(\d+).*#', '$1', $this->getUrl()); + return (int) preg_replace('#https://myanimelist.net/\w+/(\d+).*#', '$1', $this->getUrl()); } /** diff --git a/src/Parser/Club/ClubParser.php b/src/Parser/Club/ClubParser.php index af1a7b3a..db5b9e28 100644 --- a/src/Parser/Club/ClubParser.php +++ b/src/Parser/Club/ClubParser.php @@ -81,7 +81,7 @@ public function getTitle(): string /** * @return int */ - public function getMembersCount() : int + public function getMembersCount(): int { return (int) Parser::removeChildNodes( $this->crawler diff --git a/src/Parser/Club/UserProfileParser.php b/src/Parser/Club/UserProfileParser.php index 1dd34a8c..8f5c4606 100644 --- a/src/Parser/Club/UserProfileParser.php +++ b/src/Parser/Club/UserProfileParser.php @@ -68,7 +68,7 @@ public function getImage(): string } if (!str_contains($imageUrl, Constants::BASE_URL)) { - $imageUrl = Constants::BASE_URL.$imageUrl; + $imageUrl = Constants::BASE_URL . $imageUrl; } return $imageUrl; diff --git a/src/Parser/Common/AnimeCardParser.php b/src/Parser/Common/AnimeCardParser.php index 48606182..db9b514b 100644 --- a/src/Parser/Common/AnimeCardParser.php +++ b/src/Parser/Common/AnimeCardParser.php @@ -124,7 +124,7 @@ public function getEpisodes(): ?int $eps = JString::cleanse($eps->text()); $eps = str_replace(' eps', '', $eps); - return $eps === '?' ? null : (int)$eps; + return $eps === '?' ? null : (int) $eps; } /** @@ -259,7 +259,7 @@ public function getMembers(): int $count = str_replace('K', '000', $count); $count = str_replace('M', '000000', $count); - return (int)str_replace([',', '.'], '', $count); + return (int) str_replace([',', '.'], '', $count); } // producers page @@ -268,7 +268,7 @@ public function getMembers(): int if ($node->count()) { $count = JString::cleanse($node->text()); - return (int)str_replace([',', '.'], '', $count); + return (int) str_replace([',', '.'], '', $count); } } diff --git a/src/Parser/Common/ItemMetaParser.php b/src/Parser/Common/ItemMetaParser.php index 1cd968f7..a6ae2256 100644 --- a/src/Parser/Common/ItemMetaParser.php +++ b/src/Parser/Common/ItemMetaParser.php @@ -33,7 +33,7 @@ public function __construct(Crawler $crawler) */ public function getMalId(): ?int { - return (int)preg_replace('#https://myanimelist.net/\w+/(\d+).*#', '$1', $this->getUrl()); + return (int) preg_replace('#https://myanimelist.net/\w+/(\d+).*#', '$1', $this->getUrl()); } /** diff --git a/src/Parser/Common/MalUrlParser.php b/src/Parser/Common/MalUrlParser.php index 82e50cdc..c8cf6c68 100644 --- a/src/Parser/Common/MalUrlParser.php +++ b/src/Parser/Common/MalUrlParser.php @@ -54,7 +54,7 @@ public function getModel(): MalUrl return new MalUrl( JString::cleanse($this->crawler->text()), - 'https://myanimelist.net'.$href + 'https://myanimelist.net' . $href ); } } diff --git a/src/Parser/Common/MangaCardParser.php b/src/Parser/Common/MangaCardParser.php index 753adec2..4aa2da5f 100644 --- a/src/Parser/Common/MangaCardParser.php +++ b/src/Parser/Common/MangaCardParser.php @@ -193,7 +193,7 @@ public function getMembers(): int $count = str_replace('M', '000000', $count); - return (int)str_replace([',', '.'], '', $count); + return (int) str_replace([',', '.'], '', $count); } /** @@ -260,7 +260,7 @@ public function getMangaScore(): ?float return null; } - return (float)$score; + return (float) $score; } /** diff --git a/src/Parser/Common/Recommendation.php b/src/Parser/Common/Recommendation.php index 0b3792af..285316ce 100644 --- a/src/Parser/Common/Recommendation.php +++ b/src/Parser/Common/Recommendation.php @@ -98,7 +98,7 @@ public function getModel(): \Jikan\Model\Common\Recommendation return \Jikan\Model\Common\Recommendation::fromParser($this); } - public function getEntryMeta() : CommonMeta + public function getEntryMeta(): CommonMeta { return new CommonMeta( $this->getTitle(), diff --git a/src/Parser/Forum/ForumTopicParser.php b/src/Parser/Forum/ForumTopicParser.php index 6ec54113..7e447300 100644 --- a/src/Parser/Forum/ForumTopicParser.php +++ b/src/Parser/Forum/ForumTopicParser.php @@ -38,7 +38,7 @@ public function getTopicId(): int { parse_str(explode('?', $this->getUrl())[1], $query); - return (int)$query['topicid']; + return (int) $query['topicid']; } /** @@ -47,7 +47,7 @@ public function getTopicId(): int */ public function getUrl(): string { - return Constants::BASE_URL.$this->crawler->filterXPath('//a[2]')->attr('href'); + return Constants::BASE_URL . $this->crawler->filterXPath('//a[2]')->attr('href'); } /** @@ -83,7 +83,7 @@ public function getAuthorName(): string */ public function getAuthorUrl(): string { - return Constants::BASE_URL.$this->crawler->filterXPath('//span[@class="forum_postusername"]/a')->attr('href'); + return Constants::BASE_URL . $this->crawler->filterXPath('//span[@class="forum_postusername"]/a')->attr('href'); } /** @@ -92,7 +92,7 @@ public function getAuthorUrl(): string */ public function getReplies(): int { - return (int)$this->crawler->filterXPath('//td[3]')->text(); + return (int) $this->crawler->filterXPath('//td[3]')->text(); } /** @@ -102,8 +102,8 @@ public function getReplies(): int public function getLastPost(): ForumPost { $authorName = $this->crawler->filterXPath('//td[4]/a[1]')->text(); - $authorUrl = Constants::BASE_URL.$this->crawler->filterXPath('//td[4]/a[1]')->attr('href'); - $url = Constants::BASE_URL.$this->crawler->filterXPath('//td[4]/a[2]')->attr('href'); + $authorUrl = Constants::BASE_URL . $this->crawler->filterXPath('//td[4]/a[1]')->attr('href'); + $url = Constants::BASE_URL . $this->crawler->filterXPath('//td[4]/a[2]')->attr('href'); $date = Parser::removeChildNodes($this->crawler->filterXPath('//td[4]'))->text(); $date = JString::cleanse($date); $date = str_replace('by ', '', $date); diff --git a/src/Parser/Genre/AnimeGenreListItemParser.php b/src/Parser/Genre/AnimeGenreListItemParser.php index 49750fed..d2cae7cb 100644 --- a/src/Parser/Genre/AnimeGenreListItemParser.php +++ b/src/Parser/Genre/AnimeGenreListItemParser.php @@ -42,7 +42,7 @@ public function getModel(): Model\Genre\AnimeGenreListItem /** * @return int|null */ - public function getMalId() : ?int + public function getMalId(): ?int { preg_match('~(\d+)/.*$~', $this->getUrl(), $matches); diff --git a/src/Parser/Genre/AnimeGenreParser.php b/src/Parser/Genre/AnimeGenreParser.php index b14a89cf..b193dcb6 100644 --- a/src/Parser/Genre/AnimeGenreParser.php +++ b/src/Parser/Genre/AnimeGenreParser.php @@ -114,7 +114,7 @@ public function getCount(): int return 0; } - return (int)preg_replace( + return (int) preg_replace( '/\D/', '', $count->text() diff --git a/src/Parser/Genre/MangaGenreListItemParser.php b/src/Parser/Genre/MangaGenreListItemParser.php index 7e5d52b1..c29b7f8e 100644 --- a/src/Parser/Genre/MangaGenreListItemParser.php +++ b/src/Parser/Genre/MangaGenreListItemParser.php @@ -42,7 +42,7 @@ public function getModel(): Model\Genre\MangaGenreListItem /** * @return int|null */ - public function getMalId() : ?int + public function getMalId(): ?int { preg_match('~(\d+)/.*$~', $this->getUrl(), $matches); diff --git a/src/Parser/Genre/MangaGenreParser.php b/src/Parser/Genre/MangaGenreParser.php index 63e227c1..fdd534ac 100644 --- a/src/Parser/Genre/MangaGenreParser.php +++ b/src/Parser/Genre/MangaGenreParser.php @@ -64,7 +64,7 @@ function (Crawler $MangaCrawler) { */ public function getMalId(): int { - return (int)preg_replace('#https://myanimelist.net(/\w+/\w+/)(\d+).*#', '$2', $this->getUrl()); + return (int) preg_replace('#https://myanimelist.net(/\w+/\w+/)(\d+).*#', '$2', $this->getUrl()); } /** @@ -112,7 +112,7 @@ public function getCount(): int return 0; } - return (int)preg_replace( + return (int) preg_replace( '/\D/', '', $count->text() diff --git a/src/Parser/Magazine/MagazineListItemParser.php b/src/Parser/Magazine/MagazineListItemParser.php index e2cb8155..a4117ee4 100644 --- a/src/Parser/Magazine/MagazineListItemParser.php +++ b/src/Parser/Magazine/MagazineListItemParser.php @@ -42,7 +42,7 @@ public function getModel(): Model\Magazine\MagazineListItem /** * @return int|null */ - public function getMalId() : ?int + public function getMalId(): ?int { preg_match('~(\d+)/.*$~', $this->getUrl(), $matches); diff --git a/src/Parser/Manga/MangaParser.php b/src/Parser/Manga/MangaParser.php index 8e1daa5d..f4ae20be 100644 --- a/src/Parser/Manga/MangaParser.php +++ b/src/Parser/Manga/MangaParser.php @@ -55,7 +55,7 @@ public function getMangaId(): int { preg_match('#https?://myanimelist.net/manga/(\d+)#', $this->getMangaURL(), $matches); - return (int)$matches[1]; + return (int) $matches[1]; } /** @@ -237,7 +237,7 @@ public function getMangaChapters(): ?int ? null : - (int)str_replace( + (int) str_replace( $chapters->text(), '', $chapters->ancestors()->text() @@ -267,7 +267,7 @@ public function getMangaVolumes(): ?int ? null : - (int)str_replace( + (int) str_replace( $volumes->text(), '', $volumes->ancestors()->text() @@ -469,7 +469,7 @@ public function getMangaScore(): ?float return null; } - return (float)$score->text(); + return (float) $score->text(); } /** @@ -486,7 +486,7 @@ public function getMangaScoredBy(): ?int return null; } - return (int)$scoredBy->text(); + return (int) $scoredBy->text(); } /** @@ -512,7 +512,7 @@ public function getMangaRank(): ?int ) ); - return $ranked !== 'N/A' ? (int)$ranked : null; + return $ranked !== 'N/A' ? (int) $ranked : null; } /** diff --git a/src/Parser/Manga/MangaRecentlyUpdatedByUsersListParser.php b/src/Parser/Manga/MangaRecentlyUpdatedByUsersListParser.php index fa2f63bb..6b88a908 100644 --- a/src/Parser/Manga/MangaRecentlyUpdatedByUsersListParser.php +++ b/src/Parser/Manga/MangaRecentlyUpdatedByUsersListParser.php @@ -195,7 +195,7 @@ public function getModel(): MangaRecentlyUpdatedByUser return MangaRecentlyUpdatedByUser::fromParser($this); } - public function getUserMeta() : UserMeta + public function getUserMeta(): UserMeta { return new UserMeta( $this->getUsername(), diff --git a/src/Parser/Manga/MangaRecentlyUpdatedByUsersParser.php b/src/Parser/Manga/MangaRecentlyUpdatedByUsersParser.php index c7c3efe3..0346ec8d 100644 --- a/src/Parser/Manga/MangaRecentlyUpdatedByUsersParser.php +++ b/src/Parser/Manga/MangaRecentlyUpdatedByUsersParser.php @@ -51,12 +51,12 @@ function ($c) { // @todo anime user updates pagination - public function getHasNextPage() : bool + public function getHasNextPage(): bool { return false; } - public function getLastPage() : int + public function getLastPage(): int { return 1; } diff --git a/src/Parser/Manga/MangaReviewScoresParser.php b/src/Parser/Manga/MangaReviewScoresParser.php index 26b7abf0..04c33cb2 100644 --- a/src/Parser/Manga/MangaReviewScoresParser.php +++ b/src/Parser/Manga/MangaReviewScoresParser.php @@ -41,14 +41,14 @@ public function getModel(): MangaReviewScores /** * @return int */ - public function getOverallScore() : int + public function getOverallScore(): int { return (int) $this->crawler->filterXPath('//table/tr[1]/td[2]/strong')->text(); } /** * @return int */ - public function getStoryScore() : int + public function getStoryScore(): int { return (int) $this->crawler->filterXPath('//table/tr[2]/td[2]')->text(); } @@ -56,7 +56,7 @@ public function getStoryScore() : int /** * @return int */ - public function getArtScore() : int + public function getArtScore(): int { return (int) $this->crawler->filterXPath('//table/tr[3]/td[2]')->text(); } @@ -64,7 +64,7 @@ public function getArtScore() : int /** * @return int */ - public function getCharacterScore() : int + public function getCharacterScore(): int { return (int) $this->crawler->filterXPath('//table/tr[4]/td[2]')->text(); } @@ -72,7 +72,7 @@ public function getCharacterScore() : int /** * @return int */ - public function getEnjoymentScore() : int + public function getEnjoymentScore(): int { return (int) $this->crawler->filterXPath('//table/tr[5]/td[2]')->text(); } diff --git a/src/Parser/Manga/MangaReviewsParser.php b/src/Parser/Manga/MangaReviewsParser.php index 5474b52f..de9ce7ff 100644 --- a/src/Parser/Manga/MangaReviewsParser.php +++ b/src/Parser/Manga/MangaReviewsParser.php @@ -29,7 +29,7 @@ public function __construct(Crawler $crawler) $this->crawler = $crawler; } - public function getModel() : MangaReviews + public function getModel(): MangaReviews { return MangaReviews::fromParser($this); } diff --git a/src/Parser/Manga/MangaStatsParser.php b/src/Parser/Manga/MangaStatsParser.php index 780fcaa4..4194f76c 100644 --- a/src/Parser/Manga/MangaStatsParser.php +++ b/src/Parser/Manga/MangaStatsParser.php @@ -56,7 +56,7 @@ public function getReading(): int */ private function sanitize($input): int { - return (int)preg_replace('/\D/', '', $input); + return (int) preg_replace('/\D/', '', $input); } /** @@ -186,7 +186,7 @@ function (Crawler $crawler) use (&$scores) { } ); - for ($i=1; $i<=10; $i++) { + for ($i = 1; $i <= 10; $i++) { if (!array_key_exists($i, $scores)) { $scores[$i] = MangaStatsScore::setProperties(0, 0, 0); } diff --git a/src/Parser/News/NewsListItemParser.php b/src/Parser/News/NewsListItemParser.php index 13375950..f17bc1b5 100644 --- a/src/Parser/News/NewsListItemParser.php +++ b/src/Parser/News/NewsListItemParser.php @@ -55,7 +55,7 @@ public function getTitle(): string /** * @return int|null */ - public function getMalId() : ?int + public function getMalId(): ?int { preg_match('~([\d]+)$~', $this->getUrl(), $matches); @@ -72,7 +72,7 @@ public function getMalId() : ?int */ public function getUrl(): string { - return Constants::BASE_URL.$this->crawler->filterXPath('//p/a/strong/..')->attr('href'); + return Constants::BASE_URL . $this->crawler->filterXPath('//p/a/strong/..')->attr('href'); } /** @@ -116,14 +116,14 @@ public function getAuthor(): MalUrl */ public function getDiscussionLink(): string { - return Constants::BASE_URL.$this->crawler->filterXPath('//a[last()]')->attr('href'); + return Constants::BASE_URL . $this->crawler->filterXPath('//a[last()]')->attr('href'); } /** * @return int * @throws \InvalidArgumentException */ - public function getComments() : int + public function getComments(): int { $comments = $this->crawler->filterXPath('//a[last()]')->text(); preg_match('~Discuss \((\d+) comments\)~', $comments, $comments); diff --git a/src/Parser/Person/PersonParser.php b/src/Parser/Person/PersonParser.php index 21b6f408..eec26c04 100644 --- a/src/Parser/Person/PersonParser.php +++ b/src/Parser/Person/PersonParser.php @@ -53,7 +53,7 @@ public function getPersonId(): int { preg_match('#https?://myanimelist.net/people/(\d+)#', $this->getPersonURL(), $matches); - return (int)$matches[1]; + return (int) $matches[1]; } /** @@ -227,7 +227,7 @@ public function getPersonFavorites(): ?int return null; } - return (int)JString::cleanse( + return (int) JString::cleanse( str_replace([$node->text(), ','], '', $node->ancestors()->text()) ); } diff --git a/src/Parser/Producer/ProducerListItemParser.php b/src/Parser/Producer/ProducerListItemParser.php index bebcabf3..fdda98cf 100644 --- a/src/Parser/Producer/ProducerListItemParser.php +++ b/src/Parser/Producer/ProducerListItemParser.php @@ -45,7 +45,7 @@ public function getModel(): Model\Producer\ProducerListItem /** * @return int|null */ - public function getMalId() : ?int + public function getMalId(): ?int { preg_match('~(\d+)/.*$~', $this->getUrl(), $matches); diff --git a/src/Parser/Recommendations/UserRecommendationsParser.php b/src/Parser/Recommendations/UserRecommendationsParser.php index e4508b60..dcd6d3b3 100644 --- a/src/Parser/Recommendations/UserRecommendationsParser.php +++ b/src/Parser/Recommendations/UserRecommendationsParser.php @@ -95,6 +95,6 @@ public function getLastPage(): int $recommendationsCount = (int) str_replace(',', '', $pages[1]); - return ceil($recommendationsCount/30); + return ceil($recommendationsCount / 30); } } diff --git a/src/Parser/Reviews/AnimeReviewParser.php b/src/Parser/Reviews/AnimeReviewParser.php index 5cf04372..a6427960 100644 --- a/src/Parser/Reviews/AnimeReviewParser.php +++ b/src/Parser/Reviews/AnimeReviewParser.php @@ -48,7 +48,7 @@ public function getModel(): AnimeReview /** * @return AnimeMeta */ - public function getAnime(string $page = null) : AnimeMeta + public function getAnime(string $page = null): AnimeMeta { return match ($page) { 'user' => new AnimeMeta( @@ -103,12 +103,12 @@ public function getAnimeTitle(): string public function getAnimeUrl(): string { // User UserReviews page -// $node = $this->crawler -// ->filterXPath('//div[1]/div/div[2]/div/a'); -// -// if ($node->count()) { -// return $node->attr('href'); -// } + // $node = $this->crawler + // ->filterXPath('//div[1]/div/div[2]/div/a'); + // + // if ($node->count()) { + // return $node->attr('href'); + // } // Recent UserReviews page $node = $this->crawler diff --git a/src/Parser/Reviews/MangaReviewParser.php b/src/Parser/Reviews/MangaReviewParser.php index bbb214e5..ad6799fa 100644 --- a/src/Parser/Reviews/MangaReviewParser.php +++ b/src/Parser/Reviews/MangaReviewParser.php @@ -49,7 +49,7 @@ public function getModel(): MangaReview /** * @throws \Jikan\Exception\ParserException */ - public function getManga(string $page = null) : MangaMeta + public function getManga(string $page = null): MangaMeta { return match ($page) { 'user' => new MangaMeta( @@ -236,12 +236,12 @@ public function getMangaImageUrlFromUserPage(): string public function getMangaUrl(): string { // User UserReviews page -// $node = $this->crawler -// ->filterXPath('//div[1]/div/div[2]/div/a'); -// -// if ($node->count()) { -// return $node->attr('href'); -// } + // $node = $this->crawler + // ->filterXPath('//div[1]/div/div[2]/div/a'); + // + // if ($node->count()) { + // return $node->attr('href'); + // } // Recent UserReviews Anime page $node = $this->crawler diff --git a/src/Parser/Reviews/ReactionsParser.php b/src/Parser/Reviews/ReactionsParser.php index 4648ab08..6f53338a 100644 --- a/src/Parser/Reviews/ReactionsParser.php +++ b/src/Parser/Reviews/ReactionsParser.php @@ -1,4 +1,5 @@ crawler->filterXPath('//td[4]')->text(); + return (int) $this->crawler->filterXPath('//td[4]')->text(); } /** @@ -108,7 +108,7 @@ public function getEpisodes(): int */ public function getScore(): float { - return (float)$this->crawler->filterXPath('//td[5]')->text(); + return (float) $this->crawler->filterXPath('//td[5]')->text(); } /** @@ -117,7 +117,7 @@ public function getScore(): float */ public function getMembers(): int { - return (int)str_replace( + return (int) str_replace( ',', '', $this->crawler->filterXPath('//td[8]')->text() diff --git a/src/Parser/Search/CharacterSearchListItemParser.php b/src/Parser/Search/CharacterSearchListItemParser.php index 376ad50a..e3d0dac7 100644 --- a/src/Parser/Search/CharacterSearchListItemParser.php +++ b/src/Parser/Search/CharacterSearchListItemParser.php @@ -111,7 +111,7 @@ public function getAnime(): array function (Crawler $c) { return new MalUrl( $c->text(), - Constants::BASE_URL.$c->attr('href') + Constants::BASE_URL . $c->attr('href') ); } ); @@ -134,7 +134,7 @@ public function getManga(): array function (Crawler $c) { return new MalUrl( $c->text(), - Constants::BASE_URL.$c->attr('href') + Constants::BASE_URL . $c->attr('href') ); } ); diff --git a/src/Parser/Search/MangaSearchListItemParser.php b/src/Parser/Search/MangaSearchListItemParser.php index 981cda45..d411fafc 100644 --- a/src/Parser/Search/MangaSearchListItemParser.php +++ b/src/Parser/Search/MangaSearchListItemParser.php @@ -99,7 +99,7 @@ public function getType(): string */ public function getVolumes(): int { - return (int)$this->crawler->filterXPath('//td[4]')->text(); + return (int) $this->crawler->filterXPath('//td[4]')->text(); } /** @@ -108,7 +108,7 @@ public function getVolumes(): int */ public function getChapters(): int { - return (int)$this->crawler->filterXPath('//td[5]')->text(); + return (int) $this->crawler->filterXPath('//td[5]')->text(); } /** @@ -117,7 +117,7 @@ public function getChapters(): int */ public function getScore(): float { - return (float)$this->crawler->filterXPath('//td[6]')->text(); + return (float) $this->crawler->filterXPath('//td[6]')->text(); } /** @@ -186,7 +186,7 @@ public function getEndDateString(): ?string */ public function getMembers(): int { - return (int)str_replace( + return (int) str_replace( ',', '', $this->crawler->filterXPath('//td[9]')->text() diff --git a/src/Parser/SeasonList/SeasonListItemParser.php b/src/Parser/SeasonList/SeasonListItemParser.php index 50a3d82a..e145add3 100644 --- a/src/Parser/SeasonList/SeasonListItemParser.php +++ b/src/Parser/SeasonList/SeasonListItemParser.php @@ -44,7 +44,7 @@ public function getModel(): SeasonListItem */ public function getYear(): int { - return (int)preg_replace( + return (int) preg_replace( '/\D/', '', $this->crawler diff --git a/src/Parser/SeasonList/SeasonListParser.php b/src/Parser/SeasonList/SeasonListParser.php index c83611a3..6892c962 100644 --- a/src/Parser/SeasonList/SeasonListParser.php +++ b/src/Parser/SeasonList/SeasonListParser.php @@ -33,7 +33,7 @@ public function __construct(Crawler $crawler) /** * @return SeasonArchive */ - public function getModel() : SeasonArchive + public function getModel(): SeasonArchive { return SeasonArchive::fromParser($this); } diff --git a/src/Parser/Top/TopListItemParser.php b/src/Parser/Top/TopListItemParser.php index 34313bf4..4883b847 100644 --- a/src/Parser/Top/TopListItemParser.php +++ b/src/Parser/Top/TopListItemParser.php @@ -83,7 +83,7 @@ public function getImage(): ?string */ public function getRank(): int { - return (int)$this->crawler->filterXPath('//td[1]/span')->text(); + return (int) $this->crawler->filterXPath('//td[1]/span')->text(); } /** @@ -153,7 +153,7 @@ public function getVolumes(): ?int $count = 0; $vols = preg_replace('/.*\((\d+) vols\).*/', '$1', $this->getTextArray()[0], -1, $count); - return $count ? (int)$vols : null; + return $count ? (int) $vols : null; } /** @@ -162,7 +162,7 @@ public function getVolumes(): ?int */ public function getMembers(): int { - return (int)preg_replace('/\D/', '', $this->getTextArray()[2]); + return (int) preg_replace('/\D/', '', $this->getTextArray()[2]); } /** @@ -234,7 +234,7 @@ function (Crawler $crawler) { */ public function getFavorites(): int { - return (int)preg_replace('/\D/', '', $this->crawler->filterXPath('//td[5]')->text()); + return (int) preg_replace('/\D/', '', $this->crawler->filterXPath('//td[5]')->text()); } @@ -244,7 +244,7 @@ public function getFavorites(): int */ public function getPeopleFavorites(): int { - return (int)preg_replace('/\D/', '', $this->crawler->filterXPath('//td[4]')->text()); + return (int) preg_replace('/\D/', '', $this->crawler->filterXPath('//td[4]')->text()); } /** diff --git a/src/Parser/User/Friends/FriendParser.php b/src/Parser/User/Friends/FriendParser.php index e823f087..a5ff7780 100644 --- a/src/Parser/User/Friends/FriendParser.php +++ b/src/Parser/User/Friends/FriendParser.php @@ -108,7 +108,7 @@ public function getLastOnline(): \DateTimeImmutable ); } - public function getUserMeta() : UserMeta + public function getUserMeta(): UserMeta { return new UserMeta( $this->getName(), diff --git a/src/Parser/User/Friends/FriendsParser.php b/src/Parser/User/Friends/FriendsParser.php index 835f39bb..debf34df 100644 --- a/src/Parser/User/Friends/FriendsParser.php +++ b/src/Parser/User/Friends/FriendsParser.php @@ -74,7 +74,7 @@ public function getLastPage(): int preg_match('~\?offset=(\d+)$~', $pages->attr('href'), $page); - return ((int) $page[1]/100) + 1; + return ((int) $page[1] / 100) + 1; } /** diff --git a/src/Parser/User/History/HistoryItemParser.php b/src/Parser/User/History/HistoryItemParser.php index abaa8b84..cdf760cf 100644 --- a/src/Parser/User/History/HistoryItemParser.php +++ b/src/Parser/User/History/HistoryItemParser.php @@ -61,7 +61,7 @@ public function getUrl(): MalUrl throw new ParserException('Could not parse MalUrl'); } - $url = Constants::BASE_URL.'/'.$matches[1].'/'.$matches[2]; + $url = Constants::BASE_URL . '/' . $matches[1] . '/' . $matches[2]; return new MalUrl($name, $url); } @@ -72,7 +72,7 @@ public function getUrl(): MalUrl */ public function getIncrement(): int { - return (int)$this->crawler->filterXPath('//td[1]/strong')->text(); + return (int) $this->crawler->filterXPath('//td[1]/strong')->text(); } /** diff --git a/src/Parser/User/History/HistoryParser.php b/src/Parser/User/History/HistoryParser.php index 9cb12d92..ec953c3a 100644 --- a/src/Parser/User/History/HistoryParser.php +++ b/src/Parser/User/History/HistoryParser.php @@ -40,7 +40,7 @@ public function getModel(): array return $node ->reduce( function (Crawler $c) { - return (bool)$c->filterXPath('//td[contains(@class, "borderClass")]')->count(); + return (bool) $c->filterXPath('//td[contains(@class, "borderClass")]')->count(); } ) ->each( diff --git a/src/Parser/User/Profile/FavoritesParser.php b/src/Parser/User/Profile/FavoritesParser.php index 157c6a2d..1590fcfe 100644 --- a/src/Parser/User/Profile/FavoritesParser.php +++ b/src/Parser/User/Profile/FavoritesParser.php @@ -96,7 +96,7 @@ public function getCharacters(): array function (Crawler $crawler) { return new CharacterMeta( $crawler->filterXPath('//a/span[contains(@class, \'title\')]')->text(), - Constants::BASE_URL.$crawler->filterXPath('//a')->attr('href'), + Constants::BASE_URL . $crawler->filterXPath('//a')->attr('href'), Parser::parseImageQuality($crawler->filterXPath('//a/img') ->attr('data-src')), ); @@ -115,7 +115,7 @@ public function getPeople(): array function (Crawler $crawler) { return new PersonMeta( $crawler->filterXPath('//a/span[contains(@class, \'title\')]')->text(), - Constants::BASE_URL.$crawler->filterXPath('//a')->attr('href'), + Constants::BASE_URL . $crawler->filterXPath('//a')->attr('href'), Parser::parseImageQuality($crawler->filterXPath('//a/img') ->attr('data-src')), ); diff --git a/src/Parser/User/Profile/UserProfileParser.php b/src/Parser/User/Profile/UserProfileParser.php index 3be7ba28..e8136aaa 100644 --- a/src/Parser/User/Profile/UserProfileParser.php +++ b/src/Parser/User/Profile/UserProfileParser.php @@ -54,7 +54,7 @@ public function getUserId(): ?int preg_match('#id=(.*)#', $node->attr('href'), $id); if (!empty($id)) { - return (int)$id[1]; + return (int) $id[1]; } return null; diff --git a/src/Parser/User/Reviews/UserReviewsParser.php b/src/Parser/User/Reviews/UserReviewsParser.php index 09655a97..93962c29 100644 --- a/src/Parser/User/Reviews/UserReviewsParser.php +++ b/src/Parser/User/Reviews/UserReviewsParser.php @@ -34,7 +34,7 @@ public function getModel(): Model\User\Reviews\UserReviews return Model\User\Reviews\UserReviews::fromParser($this); } - public function getReviews() : array + public function getReviews(): array { $node = $this->crawler->filterXPath('//*[@id="content"]/table/tr/td[2]//div[contains(@class, "review-element")]'); @@ -54,13 +54,13 @@ public function getReviews() : array } }); } - public function hasNextPage() : bool + public function hasNextPage(): bool { // TODO: Add implementation return true; } - public function getLastVisiblePage() : ?int + public function getLastVisiblePage(): ?int { // TODO: Add implementation return 1; diff --git a/src/Parser/User/UsernameByIdParser.php b/src/Parser/User/UsernameByIdParser.php index f0ee0d7f..fea10822 100644 --- a/src/Parser/User/UsernameByIdParser.php +++ b/src/Parser/User/UsernameByIdParser.php @@ -31,7 +31,7 @@ public function __construct(Crawler $crawler) $this->crawler = $crawler; } - public function getUser() : Model\Common\UserMetaBasic + public function getUser(): Model\Common\UserMetaBasic { $node = $this->crawler->filterXPath("//*[@id=\"content\"]/div[1]/div[1]/a"); diff --git a/src/Parser/Watch/EpisodeListItemParser.php b/src/Parser/Watch/EpisodeListItemParser.php index 140d0964..8c218af3 100644 --- a/src/Parser/Watch/EpisodeListItemParser.php +++ b/src/Parser/Watch/EpisodeListItemParser.php @@ -120,14 +120,14 @@ public function getEpisodes(): array return $episodes; } - public function getRegionLocked() : bool + public function getRegionLocked(): bool { $node = $this->crawler->filterXPath('//div[contains(@class, "is_blocked")]'); return $node->count(); } - public function getAnimeMeta() : AnimeMeta + public function getAnimeMeta(): AnimeMeta { return new AnimeMeta( $this->getTitle(), diff --git a/src/Parser/Watch/WatchEpisodesParser.php b/src/Parser/Watch/WatchEpisodesParser.php index a2e8afff..b696e4f6 100644 --- a/src/Parser/Watch/WatchEpisodesParser.php +++ b/src/Parser/Watch/WatchEpisodesParser.php @@ -32,7 +32,7 @@ public function getModel(): Model\Watch\Episodes return Model\Watch\Episodes::fromParser($this); } - public function getResults() : array + public function getResults(): array { $node = $this->crawler->filterXPath( '//*[@id="content"]/div[3]/div/div[contains(@class, "video-list-outer-vertical")] diff --git a/src/Parser/Watch/WatchPromotionalVideosParser.php b/src/Parser/Watch/WatchPromotionalVideosParser.php index bb53c440..56de2f02 100644 --- a/src/Parser/Watch/WatchPromotionalVideosParser.php +++ b/src/Parser/Watch/WatchPromotionalVideosParser.php @@ -32,7 +32,7 @@ public function getModel(): Model\Watch\PromotionalVideos return Model\Watch\PromotionalVideos::fromParser($this); } - public function getResults() : array + public function getResults(): array { $node = $this->crawler->filterXPath( '//*[@id="content"]/div[3]/div/div[contains(@class, "video-list-outer-vertical")]' @@ -47,7 +47,7 @@ public function getResults() : array }); } - public function getHasNextPage() : bool + public function getHasNextPage(): bool { $node = $this->crawler->filterXPath( '//*[@id="content"]/div[contains(@class, "pagination")]/a[contains(text(), "More")]' @@ -60,7 +60,7 @@ public function getHasNextPage() : bool return false; } - public function getLastVisiblePage() : int + public function getLastVisiblePage(): int { $node = $this->crawler->filterXPath( '//*[@id="content"]/div[contains(@class, "pagination")]/span[@class="link-blue-box"]' diff --git a/src/Request/Anime/AnimeForumRequest.php b/src/Request/Anime/AnimeForumRequest.php index 83ee686c..675acf5a 100644 --- a/src/Request/Anime/AnimeForumRequest.php +++ b/src/Request/Anime/AnimeForumRequest.php @@ -45,7 +45,7 @@ public function getPath(): string { $query = ''; if ($this->topic !== null && \in_array($this->topic, self::$validTypes, true)) { - $query = '?'.http_build_query(['topic' => $this->topic]); + $query = '?' . http_build_query(['topic' => $this->topic]); } return sprintf('https://myanimelist.net/anime/%s/_/forum%s', $this->id, $query); diff --git a/src/Request/Anime/AnimeReviewsRequest.php b/src/Request/Anime/AnimeReviewsRequest.php index fa22e4ac..c67b22d4 100644 --- a/src/Request/Anime/AnimeReviewsRequest.php +++ b/src/Request/Anime/AnimeReviewsRequest.php @@ -57,12 +57,12 @@ public function __construct(int $id, int $page = 1, string $sort = Constants::RE */ public function getPath(): string { - $query = '?'.http_build_query( + $query = '?' . http_build_query( [ 'spoiler' => $this->spoilers ? 'on' : 'off', 'preliminary' => $this->preliminary ? 'on' : 'off', 'sort' => $this->sort, - 'p' => $this->page + 'p' => $this->page, ] ); diff --git a/src/Request/Manga/MangaForumRequest.php b/src/Request/Manga/MangaForumRequest.php index 81e50879..acaf7ad3 100644 --- a/src/Request/Manga/MangaForumRequest.php +++ b/src/Request/Manga/MangaForumRequest.php @@ -45,7 +45,7 @@ public function getPath(): string { $query = ''; if ($this->topic !== null && \in_array($this->topic, self::$validTypes, true)) { - $query = '?'.http_build_query(['topic' => $this->topic]); + $query = '?' . http_build_query(['topic' => $this->topic]); } return sprintf('https://myanimelist.net/manga/%s/_/forum%s', $this->id, $query); diff --git a/src/Request/Manga/MangaReviewsRequest.php b/src/Request/Manga/MangaReviewsRequest.php index bf08c0d0..2b16c930 100644 --- a/src/Request/Manga/MangaReviewsRequest.php +++ b/src/Request/Manga/MangaReviewsRequest.php @@ -57,12 +57,12 @@ public function __construct(int $id, int $page = 1, string $sort = Constants::RE */ public function getPath(): string { - $query = '?'.http_build_query( + $query = '?' . http_build_query( [ 'spoiler' => $this->spoilers ? 'on' : 'off', 'preliminary' => $this->preliminary ? 'on' : 'off', 'sort' => $this->sort, - 'p' => $this->page + 'p' => $this->page, ] ); diff --git a/src/Request/Recommendations/RecentRecommendationsRequest.php b/src/Request/Recommendations/RecentRecommendationsRequest.php index cf7287ec..ac522ec9 100644 --- a/src/Request/Recommendations/RecentRecommendationsRequest.php +++ b/src/Request/Recommendations/RecentRecommendationsRequest.php @@ -39,7 +39,7 @@ public function __construct(string $type = Constants::RECENT_RECOMMENDATION_ANIM $type, [ Constants::RECENT_RECOMMENDATION_ANIME, - Constants::RECENT_RECOMMENDATION_MANGA + Constants::RECENT_RECOMMENDATION_MANGA, ], true ) @@ -58,11 +58,11 @@ public function __construct(string $type = Constants::RECENT_RECOMMENDATION_ANIM */ public function getPath(): string { - return 'https://myanimelist.net/recommendations.php?'.http_build_query( + return 'https://myanimelist.net/recommendations.php?' . http_build_query( [ 's' => 'recentrecs', 't' => $this->type, - 'show' => ($this->page !== 1) ? 100 * ($this->page - 1) : null + 'show' => ($this->page !== 1) ? 100 * ($this->page - 1) : null, ] ); } diff --git a/src/Request/Reviews/ReviewsRequest.php b/src/Request/Reviews/ReviewsRequest.php index fa2b8567..176bb90a 100644 --- a/src/Request/Reviews/ReviewsRequest.php +++ b/src/Request/Reviews/ReviewsRequest.php @@ -69,7 +69,7 @@ public function __construct($type = Constants::ANIME, int $page = 1, string $sor */ public function getPath(): string { - return 'https://myanimelist.net/reviews.php?'.http_build_query( + return 'https://myanimelist.net/reviews.php?' . http_build_query( [ 'p' => $this->page, 't' => $this->type, diff --git a/src/Request/Search/AnimeSearchRequest.php b/src/Request/Search/AnimeSearchRequest.php index 9132ea71..ae16dd41 100644 --- a/src/Request/Search/AnimeSearchRequest.php +++ b/src/Request/Search/AnimeSearchRequest.php @@ -97,7 +97,7 @@ public function __construct(?string $query = null, int $page = 1) $this->query = $query; $this->page = $page; - $this->query = $this->query ?? ''; + $this->query ??= ''; $querySize = strlen($this->query); @@ -129,16 +129,16 @@ public function getPath(): string 'ed' => $this->endDate[0], 'em' => $this->endDate[1], 'ey' => $this->endDate[2], - 'gx' => (int)$this->genreExclude, + 'gx' => (int) $this->genreExclude, 'o' => $this->orderBy, - 'w' => $this->sort + 'w' => $this->sort, ] ); // Add genre[]= if (!empty($this->genre)) { foreach ($this->genre as $genre) { - $query .= '&genre[]='.$genre; + $query .= '&genre[]=' . $genre; } } @@ -156,7 +156,7 @@ public function getPath(): string public function setQuery(?string $query = null): self { $this->query = $query; - $this->query = $this->query ?? ''; + $this->query ??= ''; return $this; } diff --git a/src/Request/Search/CharacterSearchRequest.php b/src/Request/Search/CharacterSearchRequest.php index ed775ca8..3755443e 100644 --- a/src/Request/Search/CharacterSearchRequest.php +++ b/src/Request/Search/CharacterSearchRequest.php @@ -42,7 +42,7 @@ public function __construct(?string $query = null, int $page = 1) $this->query = $query; $this->page = $page; - $this->query = $this->query ?? ''; + $this->query ??= ''; $querySize = strlen($this->query); @@ -80,7 +80,7 @@ public function getPath(): string public function setQuery(?string $query = null): self { $this->query = $query; - $this->query = $this->query ?? ''; + $this->query ??= ''; return $this; } diff --git a/src/Request/Search/MangaSearchRequest.php b/src/Request/Search/MangaSearchRequest.php index bbc31f1a..9ad95414 100644 --- a/src/Request/Search/MangaSearchRequest.php +++ b/src/Request/Search/MangaSearchRequest.php @@ -92,7 +92,7 @@ public function __construct(?string $query = null, int $page = 1) $this->query = $query; $this->page = $page; - $this->query = $this->query ?? ''; + $this->query ??= ''; $querySize = strlen($this->query); @@ -123,16 +123,16 @@ public function getPath(): string 'ed' => $this->endDate[0], 'em' => $this->endDate[1], 'ey' => $this->endDate[2], - 'gx' => (int)$this->genreExclude, + 'gx' => (int) $this->genreExclude, 'o' => $this->orderBy, - 'w' => $this->sort + 'w' => $this->sort, ] ); // Add genre[]= if (!empty($this->genre)) { foreach ($this->genre as $genre) { - $query .= '&genre[]='.$genre; + $query .= '&genre[]=' . $genre; } } @@ -150,7 +150,7 @@ public function getPath(): string public function setQuery(?string $query = null): self { $this->query = $query; - $this->query = $this->query ?? ''; + $this->query ??= ''; return $this; } diff --git a/src/Request/Search/PersonSearchRequest.php b/src/Request/Search/PersonSearchRequest.php index 71a731f7..64960c3b 100644 --- a/src/Request/Search/PersonSearchRequest.php +++ b/src/Request/Search/PersonSearchRequest.php @@ -42,7 +42,7 @@ public function __construct(?string $query = null, int $page = 1) $this->query = $query; $this->page = $page; - $this->query = $this->query ?? ''; + $this->query ??= ''; $querySize = strlen($this->query); @@ -80,7 +80,7 @@ public function getPath(): string public function setQuery(?string $query = null): self { $this->query = $query; - $this->query = $this->query ?? ''; + $this->query ??= ''; return $this; } diff --git a/src/Request/Search/UserSearchRequest.php b/src/Request/Search/UserSearchRequest.php index 0c0aee46..eeded2c9 100644 --- a/src/Request/Search/UserSearchRequest.php +++ b/src/Request/Search/UserSearchRequest.php @@ -53,7 +53,7 @@ public function __construct(?string $query = null, int $page = 1) $this->query = $query; $this->page = $page; - $this->query = $this->query ?? ''; + $this->query ??= ''; $querySize = strlen($this->query); diff --git a/src/Request/Top/TopAnimeRequest.php b/src/Request/Top/TopAnimeRequest.php index d96459d8..547368d5 100644 --- a/src/Request/Top/TopAnimeRequest.php +++ b/src/Request/Top/TopAnimeRequest.php @@ -46,7 +46,7 @@ public function __construct(int $page = 1, $type = null) Constants::TOP_SPECIAL, Constants::TOP_BY_POPULARITY, Constants::TOP_BY_FAVORITES, - Constants::TOP_ONA + Constants::TOP_ONA, ], true ) @@ -65,7 +65,7 @@ public function __construct(int $page = 1, $type = null) */ public function getPath(): string { - return 'https://myanimelist.net/topanime.php?'.http_build_query( + return 'https://myanimelist.net/topanime.php?' . http_build_query( [ 'limit' => 50 * ($this->page - 1), 'type' => $this->type, diff --git a/src/Request/Top/TopCharactersRequest.php b/src/Request/Top/TopCharactersRequest.php index 8d8c43ad..2aa0a735 100644 --- a/src/Request/Top/TopCharactersRequest.php +++ b/src/Request/Top/TopCharactersRequest.php @@ -33,7 +33,7 @@ public function __construct(int $page = 1) */ public function getPath(): string { - return 'https://myanimelist.net/character.php?'.http_build_query(['limit' => 50 * ($this->page-1)]); + return 'https://myanimelist.net/character.php?' . http_build_query(['limit' => 50 * ($this->page - 1)]); } /** diff --git a/src/Request/Top/TopMangaRequest.php b/src/Request/Top/TopMangaRequest.php index af870780..e574a784 100644 --- a/src/Request/Top/TopMangaRequest.php +++ b/src/Request/Top/TopMangaRequest.php @@ -46,7 +46,7 @@ public function __construct(int $page = 1, $type = null) Constants::TOP_MANHUA, Constants::TOP_BY_POPULARITY, Constants::TOP_BY_FAVORITES, - Constants::TOP_LIGHTNOVELS + Constants::TOP_LIGHTNOVELS, ], true ) @@ -65,7 +65,7 @@ public function __construct(int $page = 1, $type = null) */ public function getPath(): string { - return 'https://myanimelist.net/topmanga.php?'.http_build_query( + return 'https://myanimelist.net/topmanga.php?' . http_build_query( [ 'limit' => 50 * ($this->page - 1), 'type' => $this->type, diff --git a/src/Request/Top/TopPeopleRequest.php b/src/Request/Top/TopPeopleRequest.php index 245cd0b8..71c9041b 100644 --- a/src/Request/Top/TopPeopleRequest.php +++ b/src/Request/Top/TopPeopleRequest.php @@ -33,7 +33,7 @@ public function __construct(int $page = 1) */ public function getPath(): string { - return 'https://myanimelist.net/people.php?'.http_build_query(['limit' => 50 * ($this->page-1)]); + return 'https://myanimelist.net/people.php?' . http_build_query(['limit' => 50 * ($this->page - 1)]); } /** diff --git a/src/Request/User/UserAnimeListRequest.php b/src/Request/User/UserAnimeListRequest.php index 7481c5c8..d5806a8a 100644 --- a/src/Request/User/UserAnimeListRequest.php +++ b/src/Request/User/UserAnimeListRequest.php @@ -91,7 +91,7 @@ public function __construct(string $username, int $page = 1, int $status = Const */ public function getPath(): string { - $query = '?'.http_build_query( + $query = '?' . http_build_query( [ 'offset' => $this->page, 'status' => $this->status, @@ -107,7 +107,7 @@ public function getPath(): string 'aired_to_month' => $this->airedTo[1], 'aired_to_day' => $this->airedTo[2], 'producer' => $this->producer, - 'airing_status' => $this->airingStatus + 'airing_status' => $this->airingStatus, ] ); diff --git a/src/Request/User/UserFriendsRequest.php b/src/Request/User/UserFriendsRequest.php index 2245a82a..30a9ea44 100644 --- a/src/Request/User/UserFriendsRequest.php +++ b/src/Request/User/UserFriendsRequest.php @@ -39,7 +39,7 @@ public function getPath(): string { $query = ''; if ($this->page) { - $query = '?'.http_build_query(['p' => $this->page]); + $query = '?' . http_build_query(['p' => $this->page]); } return sprintf('https://myanimelist.net/profile/%s/friends%s', $this->username, $query); diff --git a/src/Request/User/UserMangaListRequest.php b/src/Request/User/UserMangaListRequest.php index 317b6c8f..cf27208e 100644 --- a/src/Request/User/UserMangaListRequest.php +++ b/src/Request/User/UserMangaListRequest.php @@ -81,7 +81,7 @@ public function __construct(string $username, int $page = 1, int $status = 7) */ public function getPath(): string { - $query = '?'.http_build_query( + $query = '?' . http_build_query( [ 'offset' => $this->page, 'status' => $this->status, @@ -95,7 +95,7 @@ public function getPath(): string 'published_to_month' => $this->publishedTo[1], 'published_to_day' => $this->publishedTo[2], 'magazine' => $this->magazine, - 'publishing_status' => $this->publishingStatus + 'publishing_status' => $this->publishingStatus, ] ); return sprintf('https://myanimelist.net/mangalist/%s/load.json%s', $this->username, $query); diff --git a/test/JikanTest/Helper/JStringTest.php b/test/unit/Helper/JStringTest.php similarity index 97% rename from test/JikanTest/Helper/JStringTest.php rename to test/unit/Helper/JStringTest.php index 92f8bbc8..841bc514 100644 --- a/test/JikanTest/Helper/JStringTest.php +++ b/test/unit/Helper/JStringTest.php @@ -3,8 +3,7 @@ namespace JikanTest\Helper; use Jikan\Helper\JString; -use Jikan\Helper\Parser; -use PHPUnit\Framework\TestCase; +use JikanTest\TestCase; /** * Class JStringTest diff --git a/test/JikanTest/Helper/MediaTest.php b/test/unit/Helper/MediaTest.php similarity index 90% rename from test/JikanTest/Helper/MediaTest.php rename to test/unit/Helper/MediaTest.php index bc9435e9..77ec81de 100644 --- a/test/JikanTest/Helper/MediaTest.php +++ b/test/unit/Helper/MediaTest.php @@ -3,8 +3,7 @@ namespace JikanTest\Helper; use Jikan\Helper\Media; -use Jikan\Helper\Parser; -use PHPUnit\Framework\TestCase; +use JikanTest\TestCase; /** * Class MediaTest diff --git a/test/JikanTest/Helper/ParserTest.php b/test/unit/Helper/ParserTest.php similarity index 98% rename from test/JikanTest/Helper/ParserTest.php rename to test/unit/Helper/ParserTest.php index 7c5a57a7..86710a4d 100644 --- a/test/JikanTest/Helper/ParserTest.php +++ b/test/unit/Helper/ParserTest.php @@ -3,7 +3,7 @@ namespace JikanTest\Helper; use Jikan\Helper\Parser; -use PHPUnit\Framework\TestCase; +use JikanTest\TestCase; /** * Class ParserTest diff --git a/test/JikanTest/HttpFilesystemCacheClientCallback.php b/test/unit/HttpFilesystemCacheClientCallback.php similarity index 78% rename from test/JikanTest/HttpFilesystemCacheClientCallback.php rename to test/unit/HttpFilesystemCacheClientCallback.php index 14a9d2a3..e5c7cf07 100644 --- a/test/JikanTest/HttpFilesystemCacheClientCallback.php +++ b/test/unit/HttpFilesystemCacheClientCallback.php @@ -1,9 +1,12 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Anime\AnimeEpisodeParser($crawler); } @@ -140,4 +141,4 @@ public function it_gets_synopsis(): void $this->parser->getSynopsis() ); } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Anime/AnimeEpisodesParserTest.php b/test/unit/Parser/Anime/AnimeEpisodesParserTest.php similarity index 97% rename from test/JikanTest/Parser/Anime/AnimeEpisodesParserTest.php rename to test/unit/Parser/Anime/AnimeEpisodesParserTest.php index 85432bfc..33eabc47 100644 --- a/test/JikanTest/Parser/Anime/AnimeEpisodesParserTest.php +++ b/test/unit/Parser/Anime/AnimeEpisodesParserTest.php @@ -2,6 +2,8 @@ namespace JikanTest\Parser\Anime; + +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; class AnimeEpisodesParserTest extends TestCase @@ -16,7 +18,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Anime\AnimeEpisodesRequest(21); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Anime\EpisodesParser($crawler); } diff --git a/test/JikanTest/Parser/Anime/AnimeMoreInfoParserTest.php b/test/unit/Parser/Anime/AnimeMoreInfoParserTest.php similarity index 89% rename from test/JikanTest/Parser/Anime/AnimeMoreInfoParserTest.php rename to test/unit/Parser/Anime/AnimeMoreInfoParserTest.php index 00af1569..70f21dc6 100644 --- a/test/JikanTest/Parser/Anime/AnimeMoreInfoParserTest.php +++ b/test/unit/Parser/Anime/AnimeMoreInfoParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Anime; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; class AnimeMoreInfoParserTest extends TestCase @@ -16,7 +17,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Anime\AnimeMoreInfoRequest(21); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Anime\MoreInfoParser($crawler); } @@ -32,4 +33,4 @@ public function it_gets_more_info(): void $this->parser->getMoreInfo() ); } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Anime/AnimeParserTest.php b/test/unit/Parser/Anime/AnimeParserTest.php similarity index 99% rename from test/JikanTest/Parser/Anime/AnimeParserTest.php rename to test/unit/Parser/Anime/AnimeParserTest.php index 8565ae87..c5a6eb1c 100644 --- a/test/JikanTest/Parser/Anime/AnimeParserTest.php +++ b/test/unit/Parser/Anime/AnimeParserTest.php @@ -1,6 +1,7 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Anime\AnimeParser($crawler); } diff --git a/test/JikanTest/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php b/test/unit/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php similarity index 97% rename from test/JikanTest/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php rename to test/unit/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php index 3f94feb9..bf01adf2 100644 --- a/test/JikanTest/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php +++ b/test/unit/Parser/Anime/AnimeRecentlyUpdatedByUsersParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Anime; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; class AnimeRecentlyUpdatedByUsersParserTest extends TestCase @@ -16,7 +17,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Anime\AnimeRecentlyUpdatedByUsersRequest(1); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->model = (new \Jikan\Parser\Anime\AnimeRecentlyUpdatedByUsersParser($crawler))->getModel(); } diff --git a/test/JikanTest/Parser/Anime/AnimeRecommendationParserTest.php b/test/unit/Parser/Anime/AnimeRecommendationParserTest.php similarity index 96% rename from test/JikanTest/Parser/Anime/AnimeRecommendationParserTest.php rename to test/unit/Parser/Anime/AnimeRecommendationParserTest.php index 4513fb73..49e06455 100644 --- a/test/JikanTest/Parser/Anime/AnimeRecommendationParserTest.php +++ b/test/unit/Parser/Anime/AnimeRecommendationParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Anime; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; class AnimeRecommendationParserTest extends TestCase @@ -16,7 +17,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Anime\AnimeRecommendationsRequest(21); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->model = (new \Jikan\Parser\Common\Recommendations($crawler))->getModel(); } diff --git a/test/JikanTest/Parser/Anime/AnimeReviewsParserTest.php b/test/unit/Parser/Anime/AnimeReviewsParserTest.php similarity index 97% rename from test/JikanTest/Parser/Anime/AnimeReviewsParserTest.php rename to test/unit/Parser/Anime/AnimeReviewsParserTest.php index a23c7219..9e864196 100644 --- a/test/JikanTest/Parser/Anime/AnimeReviewsParserTest.php +++ b/test/unit/Parser/Anime/AnimeReviewsParserTest.php @@ -2,11 +2,11 @@ namespace JikanTest\Parser\Anime; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Anime\AnimeReview; use Jikan\Parser\Anime\AnimeReviewsParser; use Jikan\Request\Anime\AnimeReviewsRequest; use JikanTest\TestCase; -use Symfony\Component\HttpClient\HttpClient; class AnimeReviewsParserTest extends TestCase { @@ -25,7 +25,7 @@ public function setUp(): void parent::setUp(); $request = new AnimeReviewsRequest(1); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->model = (new AnimeReviewsParser($crawler))->getModel(); $this->review = $this->model->getResults()[0]; diff --git a/test/JikanTest/Parser/Anime/AnimeStatsParserTest.php b/test/unit/Parser/Anime/AnimeStatsParserTest.php similarity index 93% rename from test/JikanTest/Parser/Anime/AnimeStatsParserTest.php rename to test/unit/Parser/Anime/AnimeStatsParserTest.php index 43be6230..fc76a622 100644 --- a/test/JikanTest/Parser/Anime/AnimeStatsParserTest.php +++ b/test/unit/Parser/Anime/AnimeStatsParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Anime; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Anime\AnimeStatsParser; use JikanTest\TestCase; @@ -20,7 +21,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Anime\AnimeStatsRequest(37405); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->animeStatsParser = new \Jikan\Parser\Anime\AnimeStatsParser($crawler); } diff --git a/test/JikanTest/Parser/Character/AnimeographyParserTest.php b/test/unit/Parser/Character/AnimeographyParserTest.php similarity index 94% rename from test/JikanTest/Parser/Character/AnimeographyParserTest.php rename to test/unit/Parser/Character/AnimeographyParserTest.php index 1d9c8cf2..27d0e941 100644 --- a/test/JikanTest/Parser/Character/AnimeographyParserTest.php +++ b/test/unit/Parser/Character/AnimeographyParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Character; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; /** @@ -18,7 +19,7 @@ public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/character/116281'); $crawler = $crawler->filterXPath('//div[contains(text(), \'Animeography\')]/../table/tr')->first(); $this->parser = new \Jikan\Parser\Character\AnimeographyParser($crawler); diff --git a/test/JikanTest/Parser/Character/CharacterListItemParserTest.php b/test/unit/Parser/Character/CharacterListItemParserTest.php similarity index 96% rename from test/JikanTest/Parser/Character/CharacterListItemParserTest.php rename to test/unit/Parser/Character/CharacterListItemParserTest.php index df01e2c3..953b2d6e 100644 --- a/test/JikanTest/Parser/Character/CharacterListItemParserTest.php +++ b/test/unit/Parser/Character/CharacterListItemParserTest.php @@ -2,11 +2,11 @@ namespace JikanTest\Parser\Character; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Character\VoiceActor; use Jikan\Parser\Character\CharacterListItemParser; -use JikanTest\TestCase; use Symfony\Component\DomCrawler\Crawler; +use JikanTest\TestCase; /** * Class CharacterListItemParserTest @@ -22,7 +22,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/35073/Overlord_II/characters'); $this->parser = new CharacterListItemParser( diff --git a/test/JikanTest/Parser/Character/CharacterParserTest.php b/test/unit/Parser/Character/CharacterParserTest.php similarity index 97% rename from test/JikanTest/Parser/Character/CharacterParserTest.php rename to test/unit/Parser/Character/CharacterParserTest.php index 6b2b5a29..8a7fbc6e 100644 --- a/test/JikanTest/Parser/Character/CharacterParserTest.php +++ b/test/unit/Parser/Character/CharacterParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Character; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; /** @@ -19,7 +20,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Character\CharacterRequest(116281); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Character\CharacterParser($crawler); } diff --git a/test/JikanTest/Parser/Character/StaffListItemParserTest.php b/test/unit/Parser/Character/StaffListItemParserTest.php similarity index 95% rename from test/JikanTest/Parser/Character/StaffListItemParserTest.php rename to test/unit/Parser/Character/StaffListItemParserTest.php index 77f80a03..96dc85bf 100644 --- a/test/JikanTest/Parser/Character/StaffListItemParserTest.php +++ b/test/unit/Parser/Character/StaffListItemParserTest.php @@ -2,9 +2,9 @@ namespace JikanTest\Parser\Character; -use Goutte\Client; -use JikanTest\TestCase; +use Jikan\Http\HttpClientWrapper; use Symfony\Component\DomCrawler\Crawler; +use JikanTest\TestCase; /** * Class StaffListItemParserTest @@ -20,7 +20,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/35073/_/characters'); $this->parser = new \Jikan\Parser\Anime\StaffListItemParser( diff --git a/test/JikanTest/Parser/Character/VoiceActorParserTest.php b/test/unit/Parser/Character/VoiceActorParserTest.php similarity index 94% rename from test/JikanTest/Parser/Character/VoiceActorParserTest.php rename to test/unit/Parser/Character/VoiceActorParserTest.php index 8e887e2f..55cb4b94 100644 --- a/test/JikanTest/Parser/Character/VoiceActorParserTest.php +++ b/test/unit/Parser/Character/VoiceActorParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Character; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; /** @@ -18,7 +19,7 @@ public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/character/116281'); $crawler = $crawler->filterXPath('//div[contains(text(), \'Voice Actors\')]/../table/tr')->first(); $this->parser = new \Jikan\Parser\Character\VoiceActorParser($crawler); diff --git a/test/JikanTest/Parser/Club/ClubParserTest.php b/test/unit/Parser/Club/ClubParserTest.php similarity index 97% rename from test/JikanTest/Parser/Club/ClubParserTest.php rename to test/unit/Parser/Club/ClubParserTest.php index 08cac357..2b4f181f 100644 --- a/test/JikanTest/Parser/Club/ClubParserTest.php +++ b/test/unit/Parser/Club/ClubParserTest.php @@ -1,10 +1,10 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Club\ClubParser($crawler); } diff --git a/test/JikanTest/Parser/Club/UserListParserTest.php b/test/unit/Parser/Club/UserListParserTest.php similarity index 88% rename from test/JikanTest/Parser/Club/UserListParserTest.php rename to test/unit/Parser/Club/UserListParserTest.php index d2be8cd5..f96b2d63 100644 --- a/test/JikanTest/Parser/Club/UserListParserTest.php +++ b/test/unit/Parser/Club/UserListParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Club; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; class UserListParserTest extends TestCase @@ -16,7 +17,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Club\UserListRequest(21349); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Club\UserListParser($crawler); } @@ -33,4 +34,4 @@ public function it_gets_users(): void $results ); } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/Common/MalUrlParserTest.php b/test/unit/Parser/Common/MalUrlParserTest.php similarity index 96% rename from test/JikanTest/Parser/Common/MalUrlParserTest.php rename to test/unit/Parser/Common/MalUrlParserTest.php index 93ad86b6..e31fefc1 100644 --- a/test/JikanTest/Parser/Common/MalUrlParserTest.php +++ b/test/unit/Parser/Common/MalUrlParserTest.php @@ -8,7 +8,7 @@ /** * Class MalUrlParserTest * - * @package JikanTest\Parser\Common + * @package unit\Parser\Common */ class MalUrlParserTest extends TestCase { diff --git a/test/JikanTest/Parser/Forum/ForumTopicParserTest.php b/test/unit/Parser/Forum/ForumTopicParserTest.php similarity index 96% rename from test/JikanTest/Parser/Forum/ForumTopicParserTest.php rename to test/unit/Parser/Forum/ForumTopicParserTest.php index 0e0e0480..653e8667 100644 --- a/test/JikanTest/Parser/Forum/ForumTopicParserTest.php +++ b/test/unit/Parser/Forum/ForumTopicParserTest.php @@ -4,6 +4,7 @@ namespace JikanTest\Parser\Forum; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Forum\ForumPost; use Jikan\Parser\Forum\ForumTopicParser; use JikanTest\TestCase; @@ -22,7 +23,7 @@ public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/1/_/forum'); $this->parser = new ForumTopicParser($crawler->filterXPath('//tr[contains(@id, "topicRow")]')->eq(2)); } diff --git a/test/JikanTest/Parser/Genre/AnimeGenreParserTest.php b/test/unit/Parser/Genre/AnimeGenreParserTest.php similarity index 93% rename from test/JikanTest/Parser/Genre/AnimeGenreParserTest.php rename to test/unit/Parser/Genre/AnimeGenreParserTest.php index 9bca78ee..3aab28b9 100644 --- a/test/JikanTest/Parser/Genre/AnimeGenreParserTest.php +++ b/test/unit/Parser/Genre/AnimeGenreParserTest.php @@ -2,7 +2,7 @@ namespace JikanTest\Parser\Genre; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Common\AnimeCard; use Jikan\Parser\Genre\AnimeGenreParser; use JikanTest\TestCase; @@ -21,7 +21,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/genre/1'); $this->parser = new AnimeGenreParser($crawler); } diff --git a/test/JikanTest/Parser/Genre/MangaGenreParserTest.php b/test/unit/Parser/Genre/MangaGenreParserTest.php similarity index 92% rename from test/JikanTest/Parser/Genre/MangaGenreParserTest.php rename to test/unit/Parser/Genre/MangaGenreParserTest.php index 6c966283..f47a64eb 100644 --- a/test/JikanTest/Parser/Genre/MangaGenreParserTest.php +++ b/test/unit/Parser/Genre/MangaGenreParserTest.php @@ -2,8 +2,7 @@ namespace JikanTest\Parser\Genre; -use Goutte\Client; -use Jikan\Model\Common\MalUrl; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Common\MangaCard; use Jikan\Parser\Genre\MangaGenreParser; use JikanTest\TestCase; @@ -22,7 +21,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/genre/1'); $this->parser = new MangaGenreParser($crawler); } diff --git a/test/JikanTest/Parser/Magazine/MagazineParserTest.php b/test/unit/Parser/Magazine/MagazineParserTest.php similarity index 90% rename from test/JikanTest/Parser/Magazine/MagazineParserTest.php rename to test/unit/Parser/Magazine/MagazineParserTest.php index d2424385..c784d01e 100644 --- a/test/JikanTest/Parser/Magazine/MagazineParserTest.php +++ b/test/unit/Parser/Magazine/MagazineParserTest.php @@ -2,7 +2,7 @@ namespace JikanTest\Parser\Magazine; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Magazine\MagazineParser; use JikanTest\TestCase; @@ -20,7 +20,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/magazine/1'); $this->parser = new MagazineParser($crawler); } diff --git a/test/JikanTest/Parser/Manga/CharactersParserTest.php b/test/unit/Parser/Manga/CharactersParserTest.php similarity index 91% rename from test/JikanTest/Parser/Manga/CharactersParserTest.php rename to test/unit/Parser/Manga/CharactersParserTest.php index c1bae6b7..fe5ee21e 100644 --- a/test/JikanTest/Parser/Manga/CharactersParserTest.php +++ b/test/unit/Parser/Manga/CharactersParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Manga; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Manga\CharactersParser; use JikanTest\TestCase; @@ -19,7 +20,7 @@ public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/2/Berserk/characters'); $this->parser = new CharactersParser($crawler); } diff --git a/test/JikanTest/Parser/Manga/MangaParserTest.php b/test/unit/Parser/Manga/MangaParserTest.php similarity index 98% rename from test/JikanTest/Parser/Manga/MangaParserTest.php rename to test/unit/Parser/Manga/MangaParserTest.php index d21dc5dd..5066a6d5 100644 --- a/test/JikanTest/Parser/Manga/MangaParserTest.php +++ b/test/unit/Parser/Manga/MangaParserTest.php @@ -2,10 +2,11 @@ namespace JikanTest\Parser\Manga; -use Jikan\Model\Common\Title; -use Jikan\MyAnimeList\MalClient; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Common\DateRange; use Jikan\Model\Common\MalUrl; +use Jikan\Model\Common\Title; +use Jikan\MyAnimeList\MalClient; use JikanTest\TestCase; /** @@ -28,7 +29,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Manga\MangaRequest(11); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Manga\MangaParser($crawler); diff --git a/test/JikanTest/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php b/test/unit/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php similarity index 97% rename from test/JikanTest/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php rename to test/unit/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php index 596a2ec9..f537915d 100644 --- a/test/JikanTest/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php +++ b/test/unit/Parser/Manga/MangaRecentlyUpdatedByUsersParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Manga; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; class MangaRecentlyUpdatedByUsersParserTest extends TestCase @@ -16,7 +17,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Manga\MangaRecentlyUpdatedByUsersRequest(1); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = (new \Jikan\Parser\Manga\MangaRecentlyUpdatedByUsersParser($crawler))->getModel(); } diff --git a/test/JikanTest/Parser/Manga/MangaRecommendationParserTest.php b/test/unit/Parser/Manga/MangaRecommendationParserTest.php similarity index 96% rename from test/JikanTest/Parser/Manga/MangaRecommendationParserTest.php rename to test/unit/Parser/Manga/MangaRecommendationParserTest.php index 28dbd5a0..d5e5cdfb 100644 --- a/test/JikanTest/Parser/Manga/MangaRecommendationParserTest.php +++ b/test/unit/Parser/Manga/MangaRecommendationParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Manga; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; class MangaRecommendationParserTest extends TestCase @@ -16,7 +17,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Manga\MangaRecommendationsRequest(1); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->model = (new \Jikan\Parser\Common\Recommendations($crawler))->getModel(); } diff --git a/test/JikanTest/Parser/Manga/MangaReviewsParserTest.php b/test/unit/Parser/Manga/MangaReviewsParserTest.php similarity index 97% rename from test/JikanTest/Parser/Manga/MangaReviewsParserTest.php rename to test/unit/Parser/Manga/MangaReviewsParserTest.php index 2c6ad425..a5c2be18 100644 --- a/test/JikanTest/Parser/Manga/MangaReviewsParserTest.php +++ b/test/unit/Parser/Manga/MangaReviewsParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Manga; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Manga\MangaReview; use Jikan\Parser\Manga\MangaReviewsParser; use Jikan\Request\Manga\MangaReviewsRequest; @@ -24,7 +25,7 @@ public function setUp(): void parent::setUp(); $request = new MangaReviewsRequest(1); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->model = (new MangaReviewsParser($crawler))->getModel(); $this->review = $this->model->getResults()[0]; diff --git a/test/JikanTest/Parser/Manga/MangaStatsParserTest.php b/test/unit/Parser/Manga/MangaStatsParserTest.php similarity index 93% rename from test/JikanTest/Parser/Manga/MangaStatsParserTest.php rename to test/unit/Parser/Manga/MangaStatsParserTest.php index 1410d2c2..e5217b98 100644 --- a/test/JikanTest/Parser/Manga/MangaStatsParserTest.php +++ b/test/unit/Parser/Manga/MangaStatsParserTest.php @@ -2,7 +2,7 @@ namespace JikanTest\Parser\Manga; -use Jikan\Model\Manga\MangaStatsScore; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Manga\MangaStatsParser; use JikanTest\TestCase; @@ -21,7 +21,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Manga\MangaStatsRequest(99314); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->mangaStatsParser = new MangaStatsParser($crawler); } diff --git a/test/JikanTest/Parser/News/NewsListItemParserTest.php b/test/unit/Parser/News/NewsListItemParserTest.php similarity index 92% rename from test/JikanTest/Parser/News/NewsListItemParserTest.php rename to test/unit/Parser/News/NewsListItemParserTest.php index a1f3bb77..16d81e74 100644 --- a/test/JikanTest/Parser/News/NewsListItemParserTest.php +++ b/test/unit/Parser/News/NewsListItemParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\News; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\News\NewsListItemParser; use JikanTest\TestCase; @@ -13,13 +14,13 @@ class NewsListItemParserTest extends TestCase /** * @var NewsListItemParser */ - private $parser; + private NewsListItemParser $parser; public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/2/Berserk/news'); $this->parser = new NewsListItemParser( $crawler->filterXPath('//div[contains(@class,"js-scrollfix-bottom-rel")]/div[@class="clearfix"]')->first() @@ -58,7 +59,7 @@ public function it_gets_the_image(): void */ public function it_gets_the_date(): void { - self::assertEquals('2023-06-07 00:33', $this->parser->getDate()->format('Y-m-d H:i')); + self::assertEquals('2024-06-07 00:33', $this->parser->getDate()->format('Y-m-d H:i')); } /** diff --git a/test/JikanTest/Parser/Person/PersonParserTest.php b/test/unit/Parser/Person/PersonParserTest.php similarity index 96% rename from test/JikanTest/Parser/Person/PersonParserTest.php rename to test/unit/Parser/Person/PersonParserTest.php index 086142aa..68b465be 100644 --- a/test/JikanTest/Parser/Person/PersonParserTest.php +++ b/test/unit/Parser/Person/PersonParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Person; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; /** @@ -19,7 +20,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\Person\PersonRequest(99); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new \Jikan\Parser\Person\PersonParser($crawler); } diff --git a/test/JikanTest/Parser/Pictures/PicturesPageParserTest.php b/test/unit/Parser/Pictures/PicturesPageParserTest.php similarity index 88% rename from test/JikanTest/Parser/Pictures/PicturesPageParserTest.php rename to test/unit/Parser/Pictures/PicturesPageParserTest.php index b93f8295..d4f3aa2e 100644 --- a/test/JikanTest/Parser/Pictures/PicturesPageParserTest.php +++ b/test/unit/Parser/Pictures/PicturesPageParserTest.php @@ -2,8 +2,7 @@ namespace JikanTest\Parser\Pictures; -use Goutte\Client; -use Jikan\Model\Common\Picture; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Resource\CommonImageResource\CommonImageResource; use Jikan\Parser\Common\PicturesPageParser; use JikanTest\TestCase; @@ -16,22 +15,22 @@ class PicturesPageParserTest extends TestCase /** * @var PicturesPageParser */ - private $animeParser; + private PicturesPageParser $animeParser; /** * @var PicturesPageParser */ - private $mangaParser; + private PicturesPageParser $mangaParser; /** * @var PicturesPageParser */ - private $personParser; + private PicturesPageParser $personParser; /** * @var PicturesPageParser */ - private $characterParser; + private PicturesPageParser $characterParser; /** * @test @@ -40,7 +39,7 @@ public function it_gets_manga_pictures() { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/50145/jikan/pics'); $this->mangaParser = new PicturesPageParser($crawler); $pictures = $this->mangaParser->getModel(); @@ -64,7 +63,7 @@ public function it_gets_anime_pictures() { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/22147/jikan/pics'); $this->animeParser = new PicturesPageParser($crawler); $pictures = $this->animeParser->getModel(); @@ -88,7 +87,7 @@ public function it_gets_person_pictures() { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/people/11162/jikan/pics'); $this->personParser = new PicturesPageParser($crawler); $pictures = $this->personParser->getModel(); @@ -112,7 +111,7 @@ public function it_gets_character_pictures() { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/character/105591/jikan/pics'); $this->characterParser = new PicturesPageParser($crawler); $pictures = $this->characterParser->getModel(); diff --git a/test/JikanTest/Parser/Producer/ProducerParserTest.php b/test/unit/Parser/Producer/ProducerParserTest.php similarity index 91% rename from test/JikanTest/Parser/Producer/ProducerParserTest.php rename to test/unit/Parser/Producer/ProducerParserTest.php index 6d4a23e7..e4345519 100644 --- a/test/JikanTest/Parser/Producer/ProducerParserTest.php +++ b/test/unit/Parser/Producer/ProducerParserTest.php @@ -1,8 +1,8 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/producer/1'); $this->parser = new ProducerParser($crawler); } @@ -41,7 +41,7 @@ public function it_gets_url() public function it_gets_anime() { $anime = $this->parser->getResults(); - self::assertCount(306, $anime); + self::assertCount(309, $anime); self::assertContainsOnlyInstancesOf(\Jikan\Model\Common\AnimeCard::class, $anime); } @@ -73,7 +73,7 @@ public function it_gets_established() public function it_gets_favorites() { self::assertEquals( - 4476, + 4805, $this->parser->getFavorites() ); } @@ -95,7 +95,7 @@ public function it_gets_about() public function it_gets_count() { self::assertEquals( - 306, + 309, $this->parser->getAnimeCount() ); } diff --git a/test/JikanTest/Parser/Schedule/ScheduleParserTest.php b/test/unit/Parser/Schedule/ScheduleParserTest.php similarity index 82% rename from test/JikanTest/Parser/Schedule/ScheduleParserTest.php rename to test/unit/Parser/Schedule/ScheduleParserTest.php index f1d7ff14..114bdef6 100644 --- a/test/JikanTest/Parser/Schedule/ScheduleParserTest.php +++ b/test/unit/Parser/Schedule/ScheduleParserTest.php @@ -1,8 +1,8 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/season/schedule'); $this->parser = new ScheduleParser($crawler); } @@ -33,7 +33,7 @@ public function it_gets_mondays() { $monday = $this->parser->getShedule('monday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $monday); - self::assertCount(9, $monday); + self::assertCount(11, $monday); } /** @@ -43,7 +43,7 @@ public function it_gets_tuesdays() { $tuesday = $this->parser->getShedule('tuesday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $tuesday); - self::assertCount(5, $tuesday); + self::assertCount(7, $tuesday); } /** @@ -53,7 +53,7 @@ public function it_gets_wednesdays() { $wednesday = $this->parser->getShedule('wednesday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $wednesday); - self::assertCount(11, $wednesday); + self::assertCount(9, $wednesday); } /** @@ -63,7 +63,7 @@ public function it_gets_thursdays() { $thursday = $this->parser->getShedule('thursday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $thursday); - self::assertCount(6, $thursday); + self::assertCount(9, $thursday); } /** @@ -73,7 +73,7 @@ public function it_gets_fridays() { $friday = $this->parser->getShedule('friday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $friday); - self::assertCount(9, $friday); + self::assertCount(14, $friday); } /** @@ -83,7 +83,7 @@ public function it_gets_saturdays() { $saturday = $this->parser->getShedule('saturday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $saturday); - self::assertCount(14, $saturday); + self::assertCount(17, $saturday); } /** @@ -93,7 +93,7 @@ public function it_gets_sundays() { $sunday = $this->parser->getShedule('sunday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $sunday); - self::assertCount(21, $sunday); + self::assertCount(27, $sunday); } /** @@ -103,7 +103,7 @@ public function it_gets_all() { $all = $this->parser->getShedule('all'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $all); - self::assertCount(115, $all); + self::assertCount(144, $all); } /** @@ -113,7 +113,7 @@ public function it_gets_other() { $other = $this->parser->getShedule('other'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $other); - self::assertCount(10, $other); + self::assertCount(12, $other); } /** @@ -123,6 +123,6 @@ public function it_gets_unknown() { $unknown = $this->parser->getShedule('unknown'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $unknown); - self::assertCount(21, $unknown); + self::assertCount(29, $unknown); } } diff --git a/test/JikanTest/Parser/Search/AnimeSearchAiringTest.php b/test/unit/Parser/Search/AnimeSearchAiringTest.php similarity index 100% rename from test/JikanTest/Parser/Search/AnimeSearchAiringTest.php rename to test/unit/Parser/Search/AnimeSearchAiringTest.php diff --git a/test/JikanTest/Parser/Search/AnimeSearchEpisodeTest.php b/test/unit/Parser/Search/AnimeSearchEpisodeTest.php similarity index 100% rename from test/JikanTest/Parser/Search/AnimeSearchEpisodeTest.php rename to test/unit/Parser/Search/AnimeSearchEpisodeTest.php diff --git a/test/JikanTest/Parser/Search/AnimeSearchTest.php b/test/unit/Parser/Search/AnimeSearchTest.php similarity index 94% rename from test/JikanTest/Parser/Search/AnimeSearchTest.php rename to test/unit/Parser/Search/AnimeSearchTest.php index c4db1fd2..efed184a 100644 --- a/test/JikanTest/Parser/Search/AnimeSearchTest.php +++ b/test/unit/Parser/Search/AnimeSearchTest.php @@ -100,7 +100,7 @@ public function it_gets_the_end_date() */ public function it_gets_the_members() { - self::assertEquals(1029210, $this->anime->getMembers()); + self::assertEquals(1106026, $this->anime->getMembers()); } /** @@ -116,6 +116,6 @@ public function it_gets_the_rated() */ public function it_gets_the_score() { - self::assertEquals(8.56, $this->anime->getScore()); + self::assertEquals(8.55, $this->anime->getScore()); } } diff --git a/test/JikanTest/Parser/Search/CharacterSearchTest.php b/test/unit/Parser/Search/CharacterSearchTest.php similarity index 100% rename from test/JikanTest/Parser/Search/CharacterSearchTest.php rename to test/unit/Parser/Search/CharacterSearchTest.php index 28b403e2..21983328 100644 --- a/test/JikanTest/Parser/Search/CharacterSearchTest.php +++ b/test/unit/Parser/Search/CharacterSearchTest.php @@ -3,8 +3,8 @@ namespace JikanTest\Parser\Search; use Jikan\Model\Common\MalUrl; -use JikanTest\TestCase; use Jikan\MyAnimeList\MalClient; +use JikanTest\TestCase; /** * Class CharacterSearchTest diff --git a/test/JikanTest/Parser/Search/MangaSearchTest.php b/test/unit/Parser/Search/MangaSearchTest.php similarity index 97% rename from test/JikanTest/Parser/Search/MangaSearchTest.php rename to test/unit/Parser/Search/MangaSearchTest.php index 12763392..ccfed6bd 100644 --- a/test/JikanTest/Parser/Search/MangaSearchTest.php +++ b/test/unit/Parser/Search/MangaSearchTest.php @@ -2,8 +2,8 @@ namespace JikanTest\Parser\Search; -use JikanTest\TestCase; use Jikan\MyAnimeList\MalClient; +use JikanTest\TestCase; /** * Class MangaSearchTest @@ -105,7 +105,7 @@ public function it_gets_the_end_date() */ public function it_gets_the_members() { - self::assertEquals($this->manga->getMembers(), 6906); + self::assertEquals($this->manga->getMembers(), 7680); } /** diff --git a/test/JikanTest/Parser/Search/PersonSearchTest.php b/test/unit/Parser/Search/PersonSearchTest.php similarity index 100% rename from test/JikanTest/Parser/Search/PersonSearchTest.php rename to test/unit/Parser/Search/PersonSearchTest.php diff --git a/test/JikanTest/Parser/SeasonList/SeasonListItemParserTest.php b/test/unit/Parser/SeasonList/SeasonListItemParserTest.php similarity index 78% rename from test/JikanTest/Parser/SeasonList/SeasonListItemParserTest.php rename to test/unit/Parser/SeasonList/SeasonListItemParserTest.php index 81055c3b..6677a20c 100644 --- a/test/JikanTest/Parser/SeasonList/SeasonListItemParserTest.php +++ b/test/unit/Parser/SeasonList/SeasonListItemParserTest.php @@ -1,7 +1,9 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/season/archive'); $this->parser = new SeasonListItemParser( $crawler->filterXPath('//table[contains(@class, "anime-seasonal-byseason")]/tr')->first() @@ -28,7 +30,7 @@ public function setUp(): void */ public function it_gets_the_year(): void { - self::assertEquals(2023, $this->parser->getYear()); + self::assertEquals(2024, $this->parser->getYear()); } /** diff --git a/test/JikanTest/Parser/SeasonList/SeasonListParserTest.php b/test/unit/Parser/SeasonList/SeasonListParserTest.php similarity index 90% rename from test/JikanTest/Parser/SeasonList/SeasonListParserTest.php rename to test/unit/Parser/SeasonList/SeasonListParserTest.php index 675c1c6b..4ef619b2 100644 --- a/test/JikanTest/Parser/SeasonList/SeasonListParserTest.php +++ b/test/unit/Parser/SeasonList/SeasonListParserTest.php @@ -2,7 +2,7 @@ namespace JikanTest\Parser\SeasonList; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\SeasonList\SeasonListItem; use Jikan\Parser\SeasonList\SeasonListParser; use JikanTest\TestCase; @@ -22,7 +22,7 @@ public function setUp(): void parent::setUp(); $request = new \Jikan\Request\SeasonList\SeasonListRequest(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new SeasonListParser($crawler); } diff --git a/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php b/test/unit/Parser/Seasonal/SeasonalAnimeParserTest.php similarity index 98% rename from test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php rename to test/unit/Parser/Seasonal/SeasonalAnimeParserTest.php index 6626acff..dd9ff5d8 100644 --- a/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php +++ b/test/unit/Parser/Seasonal/SeasonalAnimeParserTest.php @@ -2,9 +2,10 @@ namespace JikanTest\Parser\Seasonal; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Common\AnimeCardParser; -use JikanTest\TestCase; use Symfony\Component\DomCrawler\Crawler; +use JikanTest\TestCase; /** * Class SeasonalParserTest @@ -24,7 +25,7 @@ public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $request = new \Jikan\Request\Seasonal\SeasonalRequest(2018, 'spring'); $this->crawler = $crawler = $client->request('GET', $request->getPath()); $this->parser = new AnimeCardParser($crawler->filter('div.seasonal-anime')->first()); diff --git a/test/JikanTest/Parser/Seasonal/SeasonalParserTest.php b/test/unit/Parser/Seasonal/SeasonalParserTest.php similarity index 91% rename from test/JikanTest/Parser/Seasonal/SeasonalParserTest.php rename to test/unit/Parser/Seasonal/SeasonalParserTest.php index 21fc663b..50ed9d2e 100644 --- a/test/JikanTest/Parser/Seasonal/SeasonalParserTest.php +++ b/test/unit/Parser/Seasonal/SeasonalParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\Seasonal; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; /** @@ -18,7 +19,7 @@ public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $request = new \Jikan\Request\Seasonal\SeasonalRequest(2018, 'spring'); $crawler = $client->request('GET', $request->getPath()); $this->springParser = new \Jikan\Parser\Seasonal\SeasonalParser($crawler); diff --git a/test/JikanTest/Parser/Top/TopAnimeParserTest.php b/test/unit/Parser/Top/TopAnimeParserTest.php similarity index 95% rename from test/JikanTest/Parser/Top/TopAnimeParserTest.php rename to test/unit/Parser/Top/TopAnimeParserTest.php index 05a43892..941e6ab3 100644 --- a/test/JikanTest/Parser/Top/TopAnimeParserTest.php +++ b/test/unit/Parser/Top/TopAnimeParserTest.php @@ -2,7 +2,7 @@ namespace JikanTest\Parser\Top; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Top\TopListItemParser; use JikanTest\TestCase; @@ -20,7 +20,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/topanime.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/Top/TopCharacterParserTest.php b/test/unit/Parser/Top/TopCharacterParserTest.php similarity index 95% rename from test/JikanTest/Parser/Top/TopCharacterParserTest.php rename to test/unit/Parser/Top/TopCharacterParserTest.php index 57bd0548..e247cf71 100644 --- a/test/JikanTest/Parser/Top/TopCharacterParserTest.php +++ b/test/unit/Parser/Top/TopCharacterParserTest.php @@ -2,7 +2,7 @@ namespace JikanTest\Parser\Top; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Common\MalUrl; use Jikan\Parser\Top\TopListItemParser; use JikanTest\TestCase; @@ -21,7 +21,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/character.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/Top/TopMangaParserTest.php b/test/unit/Parser/Top/TopMangaParserTest.php similarity index 96% rename from test/JikanTest/Parser/Top/TopMangaParserTest.php rename to test/unit/Parser/Top/TopMangaParserTest.php index 8d9ef822..34206006 100644 --- a/test/JikanTest/Parser/Top/TopMangaParserTest.php +++ b/test/unit/Parser/Top/TopMangaParserTest.php @@ -2,10 +2,10 @@ namespace JikanTest\Parser\Top; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Top\TopListItemParser; -use JikanTest\TestCase; use Symfony\Component\DomCrawler\Crawler; +use JikanTest\TestCase; /** * Class TopMangaParserTest @@ -26,7 +26,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $this->crawler = $crawler = $client->request('GET', 'https://myanimelist.net/topmanga.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/Top/TopPeopleParserTest.php b/test/unit/Parser/Top/TopPeopleParserTest.php similarity index 95% rename from test/JikanTest/Parser/Top/TopPeopleParserTest.php rename to test/unit/Parser/Top/TopPeopleParserTest.php index 084fb144..bfbeb053 100644 --- a/test/JikanTest/Parser/Top/TopPeopleParserTest.php +++ b/test/unit/Parser/Top/TopPeopleParserTest.php @@ -2,7 +2,7 @@ namespace JikanTest\Parser\Top; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Parser\Top\TopListItemParser; use JikanTest\TestCase; @@ -20,7 +20,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/people.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/UserFriend/FriendParserTest.php b/test/unit/Parser/UserFriend/FriendParserTest.php similarity index 67% rename from test/JikanTest/Parser/UserFriend/FriendParserTest.php rename to test/unit/Parser/UserFriend/FriendParserTest.php index 13069f0a..14c96e14 100644 --- a/test/JikanTest/Parser/UserFriend/FriendParserTest.php +++ b/test/unit/Parser/UserFriend/FriendParserTest.php @@ -1,7 +1,8 @@ httpClient); - $crawler = $client->request('GET', 'https://myanimelist.net/profile/morshuwarrior/friends'); + $client = new HttpClientWrapper($this->httpClient); + $crawler = $client->request('GET', 'https://myanimelist.net/profile/nekomata1037/friends'); $this->parser = new \Jikan\Parser\User\Friends\FriendParser( $crawler->filterXPath( '//div[contains(@class, "boxlist-container")]/div[contains(@class, "boxlist")][3]' @@ -29,7 +30,7 @@ public function setUp(): void */ public function it_gets_the_name() { - self::assertEquals('EmperorKaido', $this->parser->getName()); + self::assertEquals('sandshark', $this->parser->getName()); } /** @@ -37,7 +38,7 @@ public function it_gets_the_name() */ public function it_gets_the_url() { - self::assertEquals('https://myanimelist.net/profile/EmperorKaido', $this->parser->getUrl()); + self::assertEquals('https://myanimelist.net/profile/sandshark', $this->parser->getUrl()); } /** @@ -46,7 +47,7 @@ public function it_gets_the_url() public function it_gets_the_avatar() { self::assertEquals( - 'https://cdn.myanimelist.net/images/userimages/5229794.jpg?t=1664642400', + 'https://cdn.myanimelist.net/s/common/userimages/7168664d-c9f3-4e6c-9936-bf7b3cb25e6b_76w?s=2f3e2ce6c0bed17cb41fd558d269f311', $this->parser->getAvatar() ); } @@ -57,7 +58,7 @@ public function it_gets_the_avatar() public function it_gets_friends_since() { self::assertEquals( - '2019-11-14 12:08', + '2018-07-26 08:45', $this->parser->getFriendsSince()->format('Y-m-d H:i') ); } diff --git a/test/JikanTest/Parser/UserHistory/UserHistoryParserTest.php b/test/unit/Parser/UserHistory/UserHistoryParserTest.php similarity index 91% rename from test/JikanTest/Parser/UserHistory/UserHistoryParserTest.php rename to test/unit/Parser/UserHistory/UserHistoryParserTest.php index 3c459ff3..b268402b 100644 --- a/test/JikanTest/Parser/UserHistory/UserHistoryParserTest.php +++ b/test/unit/Parser/UserHistory/UserHistoryParserTest.php @@ -2,6 +2,7 @@ namespace JikanTest\Parser\UserHistory; +use Jikan\Http\HttpClientWrapper; use JikanTest\TestCase; /** @@ -21,7 +22,7 @@ public function setUp(): void { parent::setUp(); - $client = new \Goutte\Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/history/morshuwarrior/'); $this->parser = (new \Jikan\Parser\User\History\HistoryParser($crawler))->getModel(); } @@ -51,4 +52,4 @@ public function it_gets_the_date() self::assertInstanceOf(\DateTimeImmutable::class, $this->parser[0]->getDate()); } -} \ No newline at end of file +} diff --git a/test/JikanTest/Parser/UserProfile/UserProfileParserTest.php b/test/unit/Parser/UserProfile/UserProfileParserTest.php similarity index 92% rename from test/JikanTest/Parser/UserProfile/UserProfileParserTest.php rename to test/unit/Parser/UserProfile/UserProfileParserTest.php index 36caca32..17276ed9 100644 --- a/test/JikanTest/Parser/UserProfile/UserProfileParserTest.php +++ b/test/unit/Parser/UserProfile/UserProfileParserTest.php @@ -1,7 +1,8 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/profile/sandshark'); $this->parser = new UserProfileParser($crawler); } @@ -46,7 +47,7 @@ public function it_gets_the_url() public function it_gets_the_image() { self::assertEquals( - 'https://cdn.myanimelist.net/images/userimages/3600201.jpg?t=1664231400', + 'https://cdn.myanimelist.net/s/common/userimages/7168664d-c9f3-4e6c-9936-bf7b3cb25e6b_225w?s=6a5507ec62b4f11918233a31f37a0490', $this->parser->getImageUrl() ); } diff --git a/test/JikanTest/Parser/Video/AnimeVideoParserTest.php b/test/unit/Parser/Video/AnimeVideoParserTest.php similarity index 87% rename from test/JikanTest/Parser/Video/AnimeVideoParserTest.php rename to test/unit/Parser/Video/AnimeVideoParserTest.php index db45be49..d81a02f3 100644 --- a/test/JikanTest/Parser/Video/AnimeVideoParserTest.php +++ b/test/unit/Parser/Video/AnimeVideoParserTest.php @@ -2,10 +2,11 @@ namespace JikanTest\Parser\Video; -use Goutte\Client; +use Jikan\Http\HttpClientWrapper; use Jikan\Model\Anime\PromoListItem; use Jikan\Model\Anime\StreamEpisodeListItem; use Jikan\Parser\Anime\VideosParser; +use JikanTest\Parser\Video\AnimeVideoParser; use JikanTest\TestCase; /** @@ -22,7 +23,7 @@ public function setUp(): void { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/1/_/video'); $this->parser = new VideosParser($crawler); } diff --git a/test/JikanTest/TestCase.php b/test/unit/TestCase.php similarity index 87% rename from test/JikanTest/TestCase.php rename to test/unit/TestCase.php index 707089ed..37c69cf2 100644 --- a/test/JikanTest/TestCase.php +++ b/test/unit/TestCase.php @@ -1,18 +1,23 @@