-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b596f4
commit 1e6d7f5
Showing
5 changed files
with
243 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Jikan\Model\Anime; | ||
|
||
use Jikan\Model\Common\Collection\Pagination; | ||
use Jikan\Model\Common\Collection\Results; | ||
use Jikan\Parser; | ||
|
||
/** | ||
* Class AnimeVideosEpisodes | ||
* | ||
* @package Jikan\Model\Anime\AnimeVideosEpisodes | ||
*/ | ||
class AnimeVideosEpisodes extends Results implements Pagination | ||
{ | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private $hasNextPage = false; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $lastVisiblePage = 1; | ||
|
||
|
||
/** | ||
* @param Parser\Anime\VideosParser $parser | ||
* @return static | ||
*/ | ||
public static function fromParser(Parser\Anime\VideosParser $parser): self | ||
{ | ||
$instance = new self(); | ||
|
||
$instance->results = $parser->getEpisodes(); | ||
$instance->hasNextPage = $parser->getHasNextPage(); | ||
$instance->lastVisiblePage = $parser->getLastPage(); | ||
|
||
return $instance; | ||
} | ||
|
||
/** | ||
* @return static | ||
*/ | ||
public static function mock() : self | ||
{ | ||
return new self(); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function hasNextPage(): bool | ||
{ | ||
return $this->hasNextPage; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getLastVisiblePage(): int | ||
{ | ||
return $this->lastVisiblePage; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getResults(): array | ||
{ | ||
return $this->results; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Jikan\Request\Anime; | ||
|
||
use Jikan\Request\RequestInterface; | ||
|
||
/** | ||
* Class AnimeVideosEpisodesRequest | ||
* | ||
* @package Jikan\Request | ||
*/ | ||
class AnimeVideosEpisodesRequest implements RequestInterface | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
private int $id; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private int $page; | ||
|
||
/** | ||
* AnimeVideosEpisodesRequest constructor. | ||
* | ||
* @param int $id | ||
*/ | ||
public function __construct(int $id, int $page) | ||
{ | ||
$this->id = $id; | ||
$this->page = $page; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPath(): string | ||
{ | ||
return sprintf('https://myanimelist.net/anime/%d/_/video?p=%d', $this->id, $this->page); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getPage(): int | ||
{ | ||
return $this->page; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters