/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("object" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected 'object'"); } parent::__construct($tree, $parent); $this->setExpandable(true); // render object $isClone = null !== $tree["refUid"]; $rightArrow = $isClone ? ">>" : "▸"; $strCollapsed = "<<4>>object<<0>>(<<5>>{$tree["class"]}<<0>>)"; $strCollapsed .= "<<6>>#{$tree["id"]}<<0>> (<<1>>{$tree["count"]}<<0>>) "; $strExpanded = $strCollapsed; $strCollapsed .= $rightArrow; $strExpanded .= "▾"; $this->setStringArrayCollapsed($this->buildTextArray($strCollapsed)); $this->setStringArrayExpanded($this->buildTextArray($strExpanded)); // add children if ($isClone) { return; } foreach ($tree["properties"] as $subTree) { $class = $subTree["class"] ? "<<5>>{$subTree["class"]}:<<0>>" : ""; $key = $subTree["static"] ? "<<2>>static:<<3>>{$subTree["access"]}:<<0>>{$class}{$subTree["name"]}" : "<<3>>{$subTree["access"]}:<<0>>{$subTree["name"]}"; $key = "[{$key}] = "; $child = NcursesVarDumpTypeAbstract::factory($subTree["value"]); $wrapper = new NcursesVarDumpTypeWrapper($child, $this, $key); $this->addChild($wrapper); } }
/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("string" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected 'string'"); } parent::__construct($tree, $parent); $strExpanded = ""; $strCollapsed = ""; // build expanded string $strExpanded = "<<4>>string<<0>>(<<1>>{$tree["length"]}<<0>>) <<1>>\"{$tree["value"]}\"<<0>>"; // build collapsed string // limits string length if it is multiline $limit = strpos($tree["value"], "\n"); $limit = false !== $limit ? $limit : $tree["length"]; $string = $tree["value"]; if ($tree["length"] > $limit) { $string = substr($tree["value"], 0, $limit) . "..."; $strCollapsed = "<<4>>string<<0>>(<<1>>{$tree["length"]}<<0>>) <<1>>\"{$string}\"<<0>> ▸"; $this->setExpandable(true); $this->setStringArrayCollapsed($this->buildTextArray($strCollapsed)); $this->setStringArrayExpanded($this->buildTextArray($strExpanded)); } else { // non expandable string $this->setStringArrayCollapsed($this->buildTextArray($strExpanded)); } }
/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("bool" != $tree["type"] && "boolean" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected one of 'bool' or 'boolean'"); } parent::__construct($tree, $parent); // build text array $str = "<<4>>bool<<0>>(<<2>>{$tree["value"]}<<0>>)"; $strArray = $this->buildTextArray($str); $this->setStringArrayCollapsed($strArray); }
/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("resource" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected 'resource'"); } parent::__construct($tree, $parent); // build text array $str = "<<4>>resource<<0>>({$tree["value"]})"; $strArray = $this->buildTextArray($str); $this->setStringArrayCollapsed($strArray); }
/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("null" != $tree["type"] && "NULL" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected 'null'"); } parent::__construct($tree, $parent); // build text array $str = "<<2>>null"; $strArray = $this->buildTextArray($str); $this->setStringArrayCollapsed($strArray); }
/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("integer" != $tree["type"] && "long" != $tree["type"] && "float" != $tree["type"] && "double" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected one of 'integer', 'long', 'float', 'double"); } parent::__construct($tree, $parent); // build text array $str = "<<4>>{$tree["type"]}<<0>>(<<1>>{$tree["value"]}<<0>>)"; $strArray = $this->buildTextArray($str); $this->setStringArrayCollapsed($strArray); }
/** * {@inheritdoc} */ public function __construct(NcursesVarDumpTypeAbstract $wrapped, NcursesVarDumpTypeAbstract $parent = null, $strPrefix = null) { parent::__construct(array(), $parent); $this->wrapped = $wrapped; $this->strPrefix = $this->buildTextArray($strPrefix); $this->strPrefixHeight = !empty($strPrefix) ? $this->calculateStringHeight($strPrefix) : 0; $this->strPrefixWidth = !empty($strPrefix) ? $this->calculateStringWidth($strPrefix) : 0; // replace children's parent $children = $this->getChildren(true); foreach ($children as $child) { $child->setParent($this); } }
/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("array" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected 'array'"); } parent::__construct($tree, $parent); $this->setExpandable(true); // render array $isClone = null !== $tree["refUid"]; $strCollapsed = "<<4>>array<<0>>(<<1>>{$tree["count"]}<<0>>) "; $strExpanded = $strCollapsed; $strCollapsed .= $isClone ? ">>" : "▸"; $strExpanded .= "▾"; $this->setStringArrayCollapsed($this->buildTextArray($strCollapsed)); $this->setStringArrayExpanded($this->buildTextArray($strExpanded)); // add children foreach ($tree["children"] as $k => $subTree) { $key = "[{$k}] = "; $child = NcursesVarDumpTypeAbstract::factory($subTree); $wrapper = new NcursesVarDumpTypeWrapper($child, $this, $key); $this->addChild($wrapper); } }