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

Commit 2bfa135

Browse files
author
anatolii
committed
issue #6
Accept array of links in addToQueue method
1 parent 7720ee9 commit 2bfa135

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/RecursivePagination.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RecursivePagination {
3434
*/
3535
public function __construct(Grabber $grabber, $xpath = []) {
3636
$this->grabber = $grabber;
37-
if (!is_string($xpath) && !is_array($xpath)) {
37+
if (!is_string($xpath) AND !is_array($xpath)) {
3838
throw new \Exception('xPath should be an array or a string');
3939
}
4040
$xpath = (array) $xpath;
@@ -48,12 +48,23 @@ public function __construct(Grabber $grabber, $xpath = []) {
4848

4949

5050
/**
51-
* @param $link
51+
* @param array|string $links
5252
* @param bool $state
53+
* @throws \Exception
5354
* @return $this
5455
*/
55-
public function addToQueue($link, $state = false) {
56-
$this->queue[$link] = $state;
56+
public function addToQueue($links = [], $state = false) {
57+
if (!is_string($links) AND !is_array($links)) {
58+
throw new \Exception('Links should be an array or a string');
59+
}
60+
$links = (array) $links;
61+
foreach ($links as $url) {
62+
if (!is_string($url)) {
63+
throw new \Exception('url should be a string');
64+
}
65+
$this->queue[$url] = $state;
66+
}
67+
5768
return $this;
5869
}
5970

0 commit comments

Comments
 (0)