Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Text.php

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

Text

Namespace

PHP_CodeSniffer\Generators

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal