| Conditions | 3 |
| Paths | 3 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | 1 | public function toJson(\DOMElement $node) |
|
| 8 | { |
||
| 9 | // check if the quote contains a cite |
||
| 10 | 1 | $cite = ''; |
|
| 11 | |||
| 12 | 1 | foreach ($node->childNodes as $child) { |
|
| 13 | // if it contains a 'cite' node, we should add it in the cite property |
||
| 14 | 1 | if ($child->nodeName == 'cite') { |
|
| 15 | 1 | $html = $child->ownerDocument->saveXML($child); |
|
| 16 | 1 | $html = preg_replace('/<(\/|)cite>/i', '', $html); |
|
| 17 | 1 | $child->parentNode->removeChild($child); |
|
| 18 | 1 | $cite = ' ' . $this->htmlToMarkdown($html); |
|
| 19 | 1 | } |
|
| 20 | 1 | } |
|
| 21 | |||
| 22 | // we use the remaining html to create the remaining text |
||
| 23 | 1 | $html = $node->ownerDocument->saveXML($node); |
|
| 24 | 1 | $html = preg_replace('/<(\/|)blockquote>/i', '', $html); |
|
| 25 | |||
| 26 | return array( |
||
| 27 | 1 | 'type' => 'quote', |
|
| 28 | 'data' => array( |
||
| 29 | 1 | 'text' => ' ' . $this->htmlToMarkdown($html), |
|
| 30 | 'cite' => $cite |
||
| 31 | 1 | ) |
|
| 32 | 1 | ); |
|
| 33 | } |
||
| 34 | |||
| 40 |