You are here

public static function Kint_Decorators_Plain::decorate in Devel 8.2

Same name and namespace in other branches
  1. 8 kint/kint/decorators/plain.php \Kint_Decorators_Plain::decorate()
1 call to Kint_Decorators_Plain::decorate()
Kint_Decorators_Plain::decorateTrace in kint/kint/decorators/plain.php

File

kint/kint/decorators/plain.php, line 51

Class

Kint_Decorators_Plain

Code

public static function decorate(kintVariableData $kintVar, $level = 0) {
  $output = '';
  if ($level === 0) {
    $name = $kintVar->name ? $kintVar->name : 'literal';
    $kintVar->name = null;
    $output .= self::_title($name);
  }
  $space = str_repeat($s = '    ', $level);
  $output .= $space . self::_drawHeader($kintVar);
  if ($kintVar->extendedValue !== null) {
    $output .= ' ' . ($kintVar->type === 'array' ? '[' : '(') . PHP_EOL;
    if (is_array($kintVar->extendedValue)) {
      foreach ($kintVar->extendedValue as $v) {
        $output .= self::decorate($v, $level + 1);
      }
    }
    elseif (is_string($kintVar->extendedValue)) {
      $output .= $space . $s . $kintVar->extendedValue . PHP_EOL;

      # depth too great or similar
    }
    else {
      $output .= self::decorate($kintVar->extendedValue, $level + 1);

      //it's kintVariableData
    }
    $output .= $space . ($kintVar->type === 'array' ? ']' : ')') . PHP_EOL;
  }
  else {
    $output .= PHP_EOL;
  }
  return $output;
}