| Conditions | 6 |
| Paths | 4 |
| Total Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function parse(DOMDocument $dom, DOMXPath $xpath) |
||
| 22 | { |
||
| 23 | $result = $xpath->query('//hr[contains(@class, "m-t-none")]'); |
||
| 24 | if ($result->length < 1) { |
||
| 25 | return ''; |
||
| 26 | } |
||
| 27 | |||
| 28 | $text = []; |
||
| 29 | for ($i = 0; $i < $result->length; $i++) { |
||
| 30 | $resultI = $result->item($i)->parentNode->childNodes; |
||
| 31 | |||
| 32 | if ($resultI->length <= 0) { |
||
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | foreach ($resultI as $node) { |
||
| 37 | $nodeText = trim($dom->saveXML($node)); |
||
| 38 | |||
| 39 | if (0 !== strpos($nodeText, '<hr class="m-t-none">')) { |
||
| 40 | continue; |
||
| 41 | } |
||
| 42 | |||
| 43 | $text[] = str_replace('<hr class="m-t-none">', '', $nodeText); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | $description = trim(implode('', $text)); |
||
| 47 | $description = preg_replace(['/\<\!\-\-.*?\-\-\>/si', '/\<script.*?\<\/script\>/si'], '', $description); |
||
| 48 | |||
| 49 | return $description; |
||
| 50 | } |
||
| 51 | } |
||
| 52 |