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

Breadcrumb

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

function ArrayKeyValue::getContent

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/ArrayKeyValue.php, line 50

Class

ArrayKeyValue
@internal

Namespace

SlevomatCodingStandard\Helpers

Code

public function getContent(File $phpcsFile, bool $normalize = false, ?string $indent = null) : string {
    if ($normalize === false) {
        return TokenHelper::getContent($phpcsFile, $this->pointerStart, $this->pointerEnd);
    }
    $content = '';
    $addCommaPtr = $this->pointerComma === null ? TokenHelper::findPreviousEffective($phpcsFile, $this->pointerEnd) : null;
    $tokens = $phpcsFile->getTokens();
    for ($pointer = $this->pointerStart; $pointer <= $this->pointerEnd; $pointer++) {
        $token = $tokens[$pointer];
        $content .= $token['content'];
        if ($pointer === $addCommaPtr) {
            $content .= ',';
        }
    }
    // Trim, but keep leading empty lines
    $content = ltrim($content, " \t");
    $content = rtrim($content);
    if ($indent !== null && strpos($content, $phpcsFile->eolChar) !== 0) {
        $content = $indent . $content;
    }
    return $content;
}

API Navigation

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