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 |
||
19 | 6 | public function toText($html) |
|
20 | { |
||
21 | 6 | $parser = new Parser(); |
|
22 | |||
23 | 6 | $xmlParser = xml_parser_create(); |
|
24 | 6 | xml_set_element_handler($xmlParser, [$parser, 'startElement'], [$parser, 'endElement']); |
|
25 | 6 | xml_set_character_data_handler($xmlParser, [$parser, 'characterData']); |
|
26 | |||
27 | 6 | $wrappedHtml = "<root>$html</root>"; |
|
28 | 6 | $returnStatus = xml_parse($xmlParser, $wrappedHtml, true); |
|
29 | |||
30 | 6 | if (!$returnStatus) { |
|
31 | return $html; |
||
32 | } |
||
33 | |||
34 | 6 | return $parser->getText(); |
|
35 | } |
||
36 | } |
||
37 |