Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2.004 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 6 | public function toText($html) |
|
22 | { |
||
23 | 6 | $parser = new Parser(); |
|
24 | |||
25 | 6 | $xmlParser = xml_parser_create(); |
|
26 | 6 | xml_set_element_handler($xmlParser, [$parser, 'startElement'], [$parser, 'endElement']); |
|
27 | 6 | xml_set_character_data_handler($xmlParser, [$parser, 'characterData']); |
|
28 | |||
29 | 6 | $wrappedHtml = "<root>$html</root>"; |
|
30 | 6 | $returnStatus = xml_parse($xmlParser, $wrappedHtml, true); |
|
31 | |||
32 | 6 | if (!$returnStatus) { |
|
33 | return $html; |
||
34 | } |
||
35 | |||
36 | 6 | return $parser->getText(); |
|
37 | } |
||
38 | } |
||
39 |