Added Microdata class and test

Microdata class allows creating MicrodataParser from different sources.
This commit is contained in:
Yusuf Kandemir
2018-11-12 15:25:04 +03:00
parent 7c3700e8cf
commit daa8efa0fa
2 changed files with 65 additions and 0 deletions

29
src/Microdata.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace YusufKandemir\MicrodataParser;
abstract class Microdata
{
public static function fromHTML($html, $documentURI = '')
{
$dom = new \DOMDocument;
$dom->loadHTML($html, LIBXML_NOERROR);
$dom->documentURI = $documentURI;
return new MicrodataParser($dom);
}
public static function fromHTMLFile($filename, $documentURI = '')
{
$dom = new \DOMDocument;
$dom->loadHTMLFile($filename);
$dom->documentURI = $documentURI;
return new MicrodataParser($dom);
}
public static function fromDOMDocument(\DOMDocument $dom)
{
return new MicrodataParser($dom);
}
}