function Text::printTextBlock
Print a text block found in a standard.
Parameters
\DOMNode $node The DOMNode object for the text block.:
Return value
void
1 call to Text::printTextBlock()
- Text::processSniff in vendor/
squizlabs/ php_codesniffer/ src/ Generators/ Text.php - Process the documentation for a single sniff.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Generators/ Text.php, line 74
Class
Namespace
PHP_CodeSniffer\GeneratorsCode
protected function printTextBlock(DOMNode $node) {
$text = trim($node->nodeValue);
$text = str_replace('<em>', '*', $text);
$text = str_replace('</em>', '*', $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
echo implode(PHP_EOL, $lines) . PHP_EOL . PHP_EOL;
}