diff --git a/src/Generators/Text.php b/src/Generators/Text.php
index 10507e7adf..8d10e55470 100644
--- a/src/Generators/Text.php
+++ b/src/Generators/Text.php
@@ -130,46 +130,13 @@ protected function getFormattedTextBlock(DOMNode $node)
}
$text = trim($text);
- $text = str_replace('', '*', $text);
- $text = str_replace('', '*', $text);
+ $text = str_replace(['', ''], '*', $text);
$nodeLines = explode("\n", $text);
- $lines = [];
-
- foreach ($nodeLines as $currentLine) {
- $currentLine = trim($currentLine);
- if ($currentLine === '') {
- // The text contained a blank line. Respect this.
- $lines[] = '';
- continue;
- }
-
- $tempLine = '';
- $words = explode(' ', $currentLine);
-
- foreach ($words as $word) {
- $currentLength = strlen($tempLine.$word);
- if ($currentLength < 99) {
- $tempLine .= $word.' ';
- continue;
- }
-
- if ($currentLength === 99 || $currentLength === 100) {
- // We are already at the edge, so we are done.
- $lines[] = $tempLine.$word;
- $tempLine = '';
- } else {
- $lines[] = rtrim($tempLine);
- $tempLine = $word.' ';
- }
- }//end foreach
-
- if ($tempLine !== '') {
- $lines[] = rtrim($tempLine);
- }
- }//end foreach
+ $nodeLines = array_map('trim', $nodeLines);
+ $text = implode(PHP_EOL, $nodeLines);
- return implode(PHP_EOL, $lines).PHP_EOL.PHP_EOL;
+ return wordwrap($text, 100, PHP_EOL).PHP_EOL.PHP_EOL;
}//end getFormattedTextBlock()
@@ -243,8 +210,7 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
$firstTitleLines[] = $tempTitle;
}
- $first = str_replace('', '', $first);
- $first = str_replace('', '', $first);
+ $first = str_replace(['', ''], '', $first);
$firstLines = explode("\n", $first);
$second = trim($secondCodeElm->nodeValue);
@@ -278,8 +244,7 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
$secondTitleLines[] = $tempTitle;
}
- $second = str_replace('', '', $second);
- $second = str_replace('', '', $second);
+ $second = str_replace(['', ''], '', $second);
$secondLines = explode("\n", $second);
$titleRow = '';