Conditions | 7 |
Paths | 7 |
Total Lines | 29 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 7 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
9 | 14 | public static function buildFromHtml($html, Token $parent = null, $throwOnError = false) |
|
10 | { |
||
11 | 14 | if (Text::isMatch($html)) { |
|
12 | 8 | return new Text($parent, $throwOnError); |
|
13 | } |
||
14 | |||
15 | 7 | if (Element::isMatch($html)) { |
|
16 | 1 | return new Element($parent, $throwOnError); |
|
17 | } |
||
18 | |||
19 | 6 | if (Comment::isMatch($html)) { |
|
20 | 1 | return new Comment($parent, $throwOnError); |
|
21 | } |
||
22 | |||
23 | 5 | if (CData::isMatch($html)) { |
|
24 | 1 | return new CData($parent, $throwOnError); |
|
25 | } |
||
26 | |||
27 | 4 | if (DocType::isMatch($html)) { |
|
28 | 1 | return new DocType($parent, $throwOnError); |
|
29 | } |
||
30 | |||
31 | // Error condition |
||
32 | 3 | if ($throwOnError) { |
|
33 | 1 | throw new TokenMatchingException(); |
|
34 | } |
||
35 | |||
36 | 2 | return false; |
|
37 | } |
||
38 | } |
||
39 |