/
TopAnime.php
73 lines (62 loc) · 1.35 KB
/
TopAnime.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Jikan\Model\Top;
use Jikan\Model\Common\Collection\Pagination;
use Jikan\Model\Common\Collection\Results;
use Jikan\Parser;
/**
* Class TopAnime
*
* @package Jikan\Model\Search\Search
*/
class TopAnime extends Results implements Pagination
{
/**
* @var bool
*/
private $hasNextPage = false;
/**
* @var int
*/
private $lastVisiblePage = 1;
/**
* @param Parser\Top\TopAnimeParser $parser
*
* @return TopAnime
* @throws \Exception
* @throws \RuntimeException
* @throws \InvalidArgumentException
*/
public static function fromParser(Parser\Top\TopAnimeParser $parser): self
{
$instance = new self();
$instance->results = $parser->getResults();
$instance->hasNextPage = $parser->getHasNextPage();
$instance->lastVisiblePage = $parser->getLastPage();
return $instance;
}
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;
}
}