You are here

public function Dbug::__construct in dBug for Drupal 8

Same name and namespace in other branches
  1. 2.0.x src/Dbug.php \Drupal\dbug\Dbug::__construct()
  2. 1.0.x src/Dbug.php \Drupal\dbug\Dbug::__construct()

Dbug constructor.

Parameters

mixed $var: The variable to debug.

string $forceType: Variable type to be forced.

bool $bCollapsed: Collapse the result?

File

src/Dbug.php, line 166

Class

Dbug
Implementation of dBug for Drupal.

Namespace

Drupal\dbug

Code

public function __construct($var, $forceType = "", $bCollapsed = FALSE) {

  // Include js and css scripts.
  if (!defined('BDBUGINIT')) {
    define("BDBUGINIT", TRUE);
  }

  // Array of variable types that can be "forced".
  $arrAccept = [
    "array",
    "object",
    "xml",
  ];
  $this->bCollapsed = $bCollapsed;
  if (in_array($forceType, $arrAccept)) {
    $this
      ->{"varIs" . ucfirst($forceType)}($var);
  }
  else {
    $this
      ->checkType($var);
  }
}