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

Commit 7d6b8ce

Browse files
author
anatolii
committed
small fixes
1 parent 2bfa135 commit 7d6b8ce

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/RecursivePagination.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class RecursivePagination {
3434
*/
3535
public function __construct(Grabber $grabber, $xpath = []) {
3636
$this->grabber = $grabber;
37-
if (!is_string($xpath) AND !is_array($xpath)) {
38-
throw new \Exception('xPath should be an array or a string');
37+
if (!is_string($xpath) and !is_array($xpath)) {
38+
throw new \InvalidArgumentException('xPath should be an array or a string');
3939
}
4040
$xpath = (array) $xpath;
4141
foreach ($xpath as $path) {
4242
if (!is_string($path)) {
43-
throw new \Exception('Incorrect xPath, should be an array or a string');
43+
throw new \InvalidArgumentException('Incorrect xPath, should be an array or a string');
4444
}
4545
$this->defaultXpath[] = $path;
4646
}
@@ -53,14 +53,14 @@ public function __construct(Grabber $grabber, $xpath = []) {
5353
* @throws \Exception
5454
* @return $this
5555
*/
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');
56+
public function addToQueue($links, $state = false) {
57+
if (!is_string($links) and !is_array($links)) {
58+
throw new \InvalidArgumentException('Links should be an array or a string');
5959
}
6060
$links = (array) $links;
6161
foreach ($links as $url) {
6262
if (!is_string($url)) {
63-
throw new \Exception('url should be a string');
63+
throw new \InvalidArgumentException('url should be a string');
6464
}
6565
$this->queue[$url] = $state;
6666
}

tests/TestGrabber.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@
22

33
namespace Xparse\RecursivePagination\Test;
44

5-
class TestGrabber extends \Fiv\Parser\Grabber
5+
use Fiv\Parser\Grabber;
6+
7+
/**
8+
*
9+
* @package Xparse\RecursivePagination\Test
10+
*/
11+
class TestGrabber extends Grabber
612
{
713

14+
/**
15+
* @return string
16+
*/
817
protected function fileDataPath() {
918
return __DIR__ . '/test-data/';
1019
}
11-
20+
21+
22+
/**
23+
* @param string $url
24+
* @return \Fiv\Parser\Dom\ElementFinder
25+
*/
1226
public function getHtml($url){
1327

1428
$fileData = file_get_contents($this->fileDataPath() . $url);

0 commit comments

Comments
 (0)