GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Microdata::fromHTML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace YusufKandemir\MicrodataParser;
4
5
abstract class Microdata
6
{
7
    /**
8
     * Creates a MicrodataParser from HTML string
9
     *
10
     * @param string $html HTML string to be parsed
11
     * @param string $documentURI DocumentURI to be used in absolutizing URIs
12
     *
13
     * @return MicrodataParser
14
     */
15 3
    public static function fromHTML(string $html, string $documentURI = '') : MicrodataParser
16
    {
17 3
        $dom = new MicrodataDOMDocument;
18 3
        $dom->loadHTML($html, LIBXML_NOERROR);
19 3
        $dom->documentURI = $documentURI;
20
21 3
        return new MicrodataParser($dom);
22
    }
23
24
    /**
25
     * Creates a MicrodataParser from a HTML file
26
     *
27
     * @param string $filename Path to the file to be parsed
28
     * @param string $documentURI DocumentURI to be used in absolutizing URIs
29
     *
30
     * @return MicrodataParser
31
     */
32 3
    public static function fromHTMLFile(string $filename, string $documentURI = '') : MicrodataParser
33
    {
34 3
        $dom = new MicrodataDOMDocument;
35 3
        $dom->loadHTMLFile($filename, LIBXML_NOERROR);
36 3
        $dom->documentURI = $documentURI;
37
38 3
        return new MicrodataParser($dom);
39
    }
40
41
    /**
42
     * Creates a MicrodataParser from a DOMDocument instance.
43
     * If you have MicrodataDOMDocument then instantiate MicrodataParser class directly to avoid conversion.
44
     *
45
     * @param \DOMDocument $domDocument DOMDocument to be parsed.
46
     * Needs to have documentURI property to be used in absolutizing URIs if wanted.
47
     *
48
     * @return MicrodataParser
49
     */
50 3
    public static function fromDOMDocument(\DOMDocument $domDocument) : MicrodataParser
51
    {
52 3
        $dom = new MicrodataDOMDocument;
53 3
        $importedNode = $dom->importNode($domDocument->documentElement, true);
54 3
        $dom->appendChild($importedNode);
55
56 3
        return new MicrodataParser($dom);
57
    }
58
}
59