Skip to content

Commit 1a1c3eb

Browse files
committed
Fixed paquettg#155, removed load method call
1 parent 8fccd89 commit 1a1c3eb

File tree

13 files changed

+91
-123
lines changed

13 files changed

+91
-123
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
### Removed
2626
- Curl interface and curl implementation has been removed.
2727
- Removed support for the depth first search option.
28-
- findById() method removed from Dom object.
28+
- `findById()` method removed from Dom object.
29+
- Removed `load()` method in Dom object.
2930

3031
## 2.2.0
3132

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require "vendor/autoload.php";
3131
use PHPHtmlParser\Dom;
3232

3333
$dom = new Dom;
34-
$dom->load('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div>');
34+
$dom->loadStr('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div>');
3535
$a = $dom->find('a')[0];
3636
echo $a->text; // "click here"
3737
```
@@ -86,7 +86,7 @@ $dom->loadFromUrl('http://google.com');
8686
$html = $dom->outerHtml;
8787

8888
// or
89-
$dom->load('http://google.com');
89+
$dom->loadFromUrl('http://google.com');
9090
$html = $dom->outerHtml; // same result as the first example
9191
```
9292

@@ -137,11 +137,11 @@ $dom->setOptions([
137137
'strict' => true, // Set a global option to enable strict html parsing.
138138
]);
139139

140-
$dom->load('http://google.com', [
140+
$dom->loadFromUrl('http://google.com', [
141141
'whitespaceTextNode' => false, // Only applies to this load.
142142
]);
143143

144-
$dom->load('http://gmail.com'); // will not have whitespaceTextNode set to false.
144+
$dom->loadFromUrl('http://gmail.com'); // will not have whitespaceTextNode set to false.
145145
```
146146

147147
At the moment we support 8 options.

src/PHPHtmlParser/Dom.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PHPHtmlParser\Exceptions\CurlException;
1616
use PHPHtmlParser\Exceptions\LogicalException;
1717
use PHPHtmlParser\Exceptions\NotLoadedException;
18-
use PHPHtmlParser\Exceptions\ParentNotFoundException;
1918
use PHPHtmlParser\Exceptions\StrictException;
2019
use PHPHtmlParser\Exceptions\UnknownChildTypeException;
2120
use Psr\Http\Client\ClientInterface;
@@ -139,29 +138,6 @@ public function __get($name)
139138
return $this->root->$name;
140139
}
141140

142-
/**
143-
* Attempts to load the dom from any resource, string, file, or URL.
144-
*
145-
* @throws ChildNotFoundException
146-
* @throws CircularException
147-
* @throws CurlException
148-
* @throws StrictException
149-
* @throws LogicalException
150-
*/
151-
public function load(string $str, array $options = []): Dom
152-
{
153-
// check if it's a file
154-
if (\strpos($str, "\n") === false && \is_file($str)) {
155-
return $this->loadFromFile($str, $options);
156-
}
157-
// check if it's a url
158-
if (\preg_match("/^https?:\/\//i", $str)) {
159-
return $this->loadFromUrl($str, $options);
160-
}
161-
162-
return $this->loadStr($str, $options);
163-
}
164-
165141
/**
166142
* Loads the dom from a document file/url.
167143
*

src/PHPHtmlParser/StaticDom.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,6 @@ public static function mount(string $className = 'Dom', ?Dom $dom = null): bool
5656
return true;
5757
}
5858

59-
/**
60-
* Creates a new dom object and calls load() on the
61-
* new object.
62-
*
63-
* @throws ChildNotFoundException
64-
* @throws CircularException
65-
* @throws CurlException
66-
* @throws StrictException
67-
*/
68-
public static function load(string $str): Dom
69-
{
70-
$dom = new Dom();
71-
self::$dom = $dom;
72-
73-
return $dom->load($str);
74-
}
75-
7659
/**
7760
* Creates a new dom object and calls loadFromFile() on the
7861
* new object.
@@ -114,6 +97,14 @@ public static function loadFromUrl(string $url, array $options = [], ClientInter
11497
return $dom->loadFromUrl($url, $options, $client, $request);
11598
}
11699

100+
public static function loadStr(string $str, array $options = []): Dom
101+
{
102+
$dom = new Dom();
103+
self::$dom = $dom;
104+
105+
return $dom->loadStr($str, $options);
106+
}
107+
117108
/**
118109
* Sets the $dom variable to null.
119110
*/

0 commit comments

Comments
 (0)