Docblocking and type hinting

This commit is contained in:
Yusuf Kandemir
2018-12-13 09:50:04 +03:00
parent 59d302176d
commit 9eaf3cbcfa
4 changed files with 138 additions and 14 deletions

View File

@ -4,7 +4,15 @@ namespace YusufKandemir\MicrodataParser;
abstract class Microdata
{
public static function fromHTML($html, $documentURI = '')
/**
* Creates a MicrodataParser from HTML string
*
* @param string $html HTML string to be parsed
* @param string $documentURI DocumentURI to be used in absolutizing URIs
*
* @return MicrodataParser
*/
public static function fromHTML(string $html, string $documentURI = '') : MicrodataParser
{
$dom = new MicrodataDOMDocument;
$dom->loadHTML($html, LIBXML_NOERROR);
@ -13,7 +21,15 @@ abstract class Microdata
return new MicrodataParser($dom);
}
public static function fromHTMLFile($filename, $documentURI = '')
/**
* Creates a MicrodataParser from a HTML file
*
* @param string $filename Path to the file to be parsed
* @param string $documentURI DocumentURI to be used in absolutizing URIs
*
* @return MicrodataParser
*/
public static function fromHTMLFile(string $filename, string $documentURI = '') : MicrodataParser
{
$dom = new MicrodataDOMDocument;
$dom->loadHTMLFile($filename, LIBXML_NOERROR);
@ -22,7 +38,16 @@ abstract class Microdata
return new MicrodataParser($dom);
}
public static function fromDOMDocument(\DOMDocument $domDocument)
/**
* Creates a MicrodataParser from a DOMDocument instance.
* If you have MicrodataDOMDocument then instantiate MicrodataParser class directly to avoid conversion.
*
* @param \DOMDocument $domDocument DOMDocument to be parsed.
* Needs to have documentURI property to be used in absolutizing URIs if wanted.
*
* @return MicrodataParser
*/
public static function fromDOMDocument(\DOMDocument $domDocument) : MicrodataParser
{
$dom = new MicrodataDOMDocument;
$importedNode = $dom->importNode($domDocument->documentElement, true);