private function assertTypeId($expectedTypeId, Object $object) { $actualType = $object->getType(); if ($expectedTypeId != $actualType) { throw new Exception("Expected type ({$expectedTypeId}) does not match actual type ({$actualType}"); } }
function printObject(Object $object, $depth = 0) { $treeSymbol = ''; $depthString = str_repeat('─', $depth); if ($depth > 0) { $treeSymbol = '├'; } $name = Identifier::getShortName($object->getType()); echo "{$treeSymbol}{$depthString}{$name} : "; echo $object->__toString() . PHP_EOL; $content = $object->getContent(); if (is_array($content)) { foreach ($object as $child) { printObject($child, $depth + 1); } } }
function printObject(Object $object, $depth = 0) { $treeSymbol = ''; $depthString = str_repeat('━', $depth); if ($depth > 0) { $treeSymbol = '┣'; } $name = strtoupper(Identifier::getShortName($object->getType())); echo "{$treeSymbol}{$depthString}<b>{$name}</b> : "; echo $object->__toString() . '<br/>'; $content = $object->getContent(); if (is_array($content)) { foreach ($object as $child) { printObject($child, $depth + 1); } } }
/** * @param OutputInterface $output * @param Object $object * @param int $depth * @return void * @throws \FG\ASN1\Exception\NotImplementedException */ private function printObject(OutputInterface $output, Object $object, $depth = 0) { $treeSymbol = ''; $depthString = str_repeat('─', $depth); if ($depth > 0) { $treeSymbol = '├'; } $name = Identifier::getShortName($object->getType()); $output->write("{$treeSymbol}{$depthString}<comment>{$name}</comment> : "); $output->writeln($object->__toString()); $content = $object->getContent(); if (is_array($content)) { foreach ($object as $child) { $this->printObject($output, $child, $depth + 1); } } }
function printObject(Object $object, $depth = 0) { $name = strtoupper(Identifier::getShortName($object->getType())); $treeSymbol = ''; $depthString = str_repeat('━', $depth); if ($depth > 0) { $treeSymbol = '┣'; $name = ' ' . $name; } echo "{$treeSymbol}{$depthString}{$name} : "; echo $object->__toString() . PHP_EOL; $content = $object->getContent(); if ($content instanceof Object) { printObject($content, $depth + 1); } elseif (is_array($content)) { foreach ($object as $child) { printObject($child, $depth + 1); } } }