Added Microdata class and test
Microdata class allows creating MicrodataParser from different sources.
This commit is contained in:
		
							
								
								
									
										29
									
								
								src/Microdata.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/Microdata.php
									
									
									
									
									
										Normal 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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user