MastermindsParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 15
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 8 2
1
<?php
2
/**
3
 * (c) Steve Nebes <[email protected]>.
4
 *
5
 *  For the full copyright and license information, please view the LICENSE
6
 *  file that was distributed with this source code.
7
 */
8
9
declare(strict_types=1);
10
11
namespace SN\HtmlSanitizer\Parser;
12
13
use DOMNode;
14
use SN\HtmlSanitizer\Exception\ParsingFailedException;
15
use Masterminds\HTML5;
16
use Throwable;
17
18
/**
19
 * @author Steve Nebes <[email protected]>
20
 *
21
 * @internal
22
 */
23
class MastermindsParser implements ParserInterface
24
{
25
    /**
26
     * @param string $html
27
     *
28
     * @return DOMNode
29
     */
30 5
    public function parse(string $html): DOMNode
31
    {
32
        try {
33 5
            $parser = new HTML5();
34
35 5
            return $parser->loadHTMLFragment($html);
36
        } catch (Throwable $t) {
37
            throw new ParsingFailedException($this, $t);
38
        }
39
    }
40
}
41