-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDOMBuilder.php
More file actions
40 lines (33 loc) · 810 Bytes
/
DOMBuilder.php
File metadata and controls
40 lines (33 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Brick\StructuredData;
use DOMDocument;
final class DOMBuilder
{
/**
* Builds a DOMDocument from an HTML string.
*
* @param string $html
*
* @return DOMDocument
*/
public static function fromHTML(string $html) : DOMDocument
{
$document = new DOMDocument();
$document->loadHTML($html, LIBXML_NOWARNING | LIBXML_NOERROR);
return $document;
}
/**
* Builds a DOMDocument from an HTML file.
*
* @param string $file
*
* @return DOMDocument
*/
public static function fromHTMLFile(string $file) : DOMDocument
{
$document = new DOMDocument();
$document->loadHTMLFile($file, LIBXML_NOWARNING | LIBXML_NOERROR);
return $document;
}
}