| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 4 | public function nl2br($var) { |
||
|
|
|||
| 5 | $parts = explode("\n", $var); |
||
| 6 | $doc = new \DomDocument(); |
||
| 7 | $root = $doc->createElement('root'); |
||
| 8 | $doc->appendChild($root); |
||
| 9 | |||
| 10 | foreach ($parts as $key => $part) { |
||
| 11 | $new = $doc->createTextNode($part); |
||
| 12 | $doc->documentElement->appendChild($new); |
||
| 13 | if ($key !== count($parts)-1) { |
||
| 14 | $br = $doc->createElement('br'); |
||
| 15 | $doc->documentElement->appendChild($br); |
||
| 16 | } |
||
| 17 | } |
||
| 18 | |||
| 19 | return $this->getContent($doc); |
||
| 20 | } |
||
| 21 | |||
| 38 |