Removed Microdata class and its test

This is related with incoming changes in future commits.
This commit is contained in:
Yusuf Kandemir 2018-12-26 08:36:03 +03:00
parent d2f6572125
commit 7bbf744a76
2 changed files with 0 additions and 94 deletions

View File

@ -1,58 +0,0 @@
<?php
namespace YusufKandemir\MicrodataParser;
abstract class Microdata
{
/**
* 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);
$dom->documentURI = $documentURI;
return new MicrodataParser($dom);
}
/**
* 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);
$dom->documentURI = $documentURI;
return new MicrodataParser($dom);
}
/**
* 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);
$dom->appendChild($importedNode);
return new MicrodataParser($dom);
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace YusufKandemir\MicrodataParser\Tests;
use YusufKandemir\MicrodataParser\Microdata;
use YusufKandemir\MicrodataParser\MicrodataParser;
class MicrodataTest extends \PHPUnit\Framework\TestCase
{
protected $htmlFileName = __DIR__ . '/data/W3C/source.html';
public function testItCreatesMicrodataParserFromHtml()
{
$html = file_get_contents($this->htmlFileName);
$microdata = Microdata::fromHTML($html);
$this->assertInstanceOf(MicrodataParser::class, $microdata);
}
public function testItCreatesMicrodataParserFromHtmlFile()
{
$microdata = Microdata::fromHTMLFile($this->htmlFileName);
$this->assertInstanceOf(MicrodataParser::class, $microdata);
}
public function testItCreatesMicrodataParserFromDomDocument()
{
$dom = new \DOMDocument;
$dom->loadHTMLFile($this->htmlFileName);
$microdata = Microdata::fromDOMDocument($dom);
$this->assertInstanceOf(MicrodataParser::class, $microdata);
}
}