Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 7720ee9

Browse files
author
anatolii
committed
issue #3 php doc comments added + formatting
issue #5 removed unused statements
1 parent b46f671 commit 7720ee9

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

src/RecursivePagination.php

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,66 @@
22

33
namespace Xparse\RecursivePagination;
44

5-
use Doctrine\Instantiator\Exception\InvalidArgumentException;
6-
use Fiv\Parser\Exception;
75

8-
class RecursivePagination
9-
{
6+
use Fiv\Parser\Grabber;
107

11-
protected $queue = array();
8+
/**
9+
*
10+
* @package Xparse\RecursivePagination
11+
*/
12+
class RecursivePagination {
1213

14+
/**
15+
* @var array
16+
*/
17+
protected $queue = [];
18+
19+
/**
20+
* @var Grabber|null
21+
*/
1322
protected $grabber = null;
1423

15-
protected $defaultXpath = array();
24+
/**
25+
* @var array
26+
*/
27+
protected $defaultXpath = [];
28+
1629

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 = []) {
1936
$this->grabber = $grabber;
2037
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');
2239
}
23-
$xpath = (array)$xpath;
40+
$xpath = (array) $xpath;
2441
foreach ($xpath as $path) {
2542
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');
2744
}
2845
$this->defaultXpath[] = $path;
2946
}
3047
}
3148

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) {
3456
$this->queue[$link] = $state;
3557
return $this;
3658
}
3759

38-
public function getNextPage()
39-
{
60+
61+
/**
62+
* @return \Fiv\Parser\Dom\ElementFinder|null
63+
*/
64+
public function getNextPage() {
4065
$page = $this->grabber->getLastPage();
4166
if (!empty($page)) {
4267
foreach ($this->defaultXpath as $xPath) {

0 commit comments

Comments
 (0)