You are here

class VarDumperConsole in VarDumper 8

Same name and namespace in other branches
  1. 7 modules/vardumper_console/src/VarDumper/VarDumperConsole.php \Drupal\vardumper_console\VarDumper\VarDumperConsole

The VarDumperConsole class.

Hierarchy

Expanded class hierarchy of VarDumperConsole

1 string reference to 'VarDumperConsole'
vardumper_console.services.yml in modules/vardumper_console/vardumper_console.services.yml
modules/vardumper_console/vardumper_console.services.yml
1 service uses VarDumperConsole
vardumper_console in modules/vardumper_console/vardumper_console.services.yml
\Drupal\vardumper_console\VarDumper\VarDumperConsole

File

modules/vardumper_console/src/VarDumper/VarDumperConsole.php, line 12

Namespace

Drupal\vardumper_console\VarDumper
View source
class VarDumperConsole extends VarDumperDebug {

  /**
   * {@inheritdoc}.
   */
  public function dump($var, $name = '') {
    $cloner = new VarCloner();
    $dumper = new CliDumper('php://stdout');
    $html = $this
      ->border(strip_tags($this
      ->getHeaders($name, $this
      ->getDebugInformation()))) . "\n";
    file_put_contents('php://stdout', $html);
    $dumper
      ->dump($cloner
      ->cloneVar($var));
  }

  /**
   * Helper method to add a border around the header in console.
   */
  private function border($string, $character = '*') {
    $string = $character . ' ' . $string . ' ' . $character;
    $line = str_repeat($character, mb_strlen($string));
    return implode("\n", [
      $line,
      $string,
      $line,
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
VarDumperConsole::border private function Helper method to add a border around the header in console.
VarDumperConsole::dump public function .
VarDumperDebug::$header1 protected property
VarDumperDebug::$header2 protected property
VarDumperDebug::getDebug public function
VarDumperDebug::getDebugInformation public function
VarDumperDebug::getHeaders public function
VarDumperDebug::hasPermission public function