|
2 | 2 |
|
3 | 3 | namespace Xparse\RecursivePagination; |
4 | 4 |
|
5 | | - use Doctrine\Instantiator\Exception\InvalidArgumentException; |
6 | | - use Fiv\Parser\Exception; |
7 | 5 |
|
8 | | - class RecursivePagination |
9 | | - { |
| 6 | + use Fiv\Parser\Grabber; |
10 | 7 |
|
11 | | - protected $queue = array(); |
| 8 | + /** |
| 9 | + * |
| 10 | + * @package Xparse\RecursivePagination |
| 11 | + */ |
| 12 | + class RecursivePagination { |
12 | 13 |
|
| 14 | + /** |
| 15 | + * @var array |
| 16 | + */ |
| 17 | + protected $queue = []; |
| 18 | + |
| 19 | + /** |
| 20 | + * @var Grabber|null |
| 21 | + */ |
13 | 22 | protected $grabber = null; |
14 | 23 |
|
15 | | - protected $defaultXpath = array(); |
| 24 | + /** |
| 25 | + * @var array |
| 26 | + */ |
| 27 | + protected $defaultXpath = []; |
| 28 | + |
16 | 29 |
|
17 | | - public function __construct(\Fiv\Parser\Grabber $grabber, $xpath = array()) |
18 | | - { |
| 30 | + /** |
| 31 | + * @param Grabber $grabber |
| 32 | + * @param array $xpath |
| 33 | + * @throws \Exception |
| 34 | + */ |
| 35 | + public function __construct(Grabber $grabber, $xpath = []) { |
19 | 36 | $this->grabber = $grabber; |
20 | 37 | if (!is_string($xpath) && !is_array($xpath)) { |
21 | | - throw new \InvalidArgumentException('xPath should be an array or a string'); |
| 38 | + throw new \Exception('xPath should be an array or a string'); |
22 | 39 | } |
23 | | - $xpath = (array)$xpath; |
| 40 | + $xpath = (array) $xpath; |
24 | 41 | foreach ($xpath as $path) { |
25 | 42 | if (!is_string($path)) { |
26 | | - throw new \InvalidArgumentException('Incorrect xPath, should be an array or a string'); |
| 43 | + throw new \Exception('Incorrect xPath, should be an array or a string'); |
27 | 44 | } |
28 | 45 | $this->defaultXpath[] = $path; |
29 | 46 | } |
30 | 47 | } |
31 | 48 |
|
32 | | - public function addToQueue($link, $state = false) |
33 | | - { |
| 49 | + |
| 50 | + /** |
| 51 | + * @param $link |
| 52 | + * @param bool $state |
| 53 | + * @return $this |
| 54 | + */ |
| 55 | + public function addToQueue($link, $state = false) { |
34 | 56 | $this->queue[$link] = $state; |
35 | 57 | return $this; |
36 | 58 | } |
37 | 59 |
|
38 | | - public function getNextPage() |
39 | | - { |
| 60 | + |
| 61 | + /** |
| 62 | + * @return \Fiv\Parser\Dom\ElementFinder|null |
| 63 | + */ |
| 64 | + public function getNextPage() { |
40 | 65 | $page = $this->grabber->getLastPage(); |
41 | 66 | if (!empty($page)) { |
42 | 67 | foreach ($this->defaultXpath as $xPath) { |
|
0 commit comments