Ejemplo n.º 1
0
 /**
  * Renders input $node as php source code.
  *
  * @param  string $varName Variable name (optional).
  * @return string          PHP code.
  */
 public static function render(Leaf $node, $varName = '')
 {
     // Validate variable name
     $varName = $varName ? $varName : $node->getID();
     $varName = self::checkVariableName($varName);
     // Object kind
     $source = '$' . $varName . ' = new \\' . get_class($node) . "([\n" . "  'kind' => '{$node->getKind()}'";
     // Object attributes
     if ($node->hasAttr()) {
         $source .= ",\n" . self::renderArray($node->getAttr(), 'attr', 1);
     }
     // Object child nodes
     if ($node->hasChildNodes()) {
         $source = rtrim($source);
         $source .= "\n" . self::renderChildNodes($node->getChildNodes(), 'child', 1);
     }
     // Content
     $source = rtrim($source);
     if ($node->hasCont()) {
         $content = wordwrap($node->getCont(), 90, "\n");
         $source .= ",\n  'cont' => '{$content}'";
     }
     // Closing brackets;
     $source .= "\n]); \n";
     return $source;
 }
Ejemplo n.º 2
0
 /**
  * Constructs object
  * @param Array|array $input
  */
 public function __construct(array $input = [])
 {
     parent::__construct($input);
     if (isset($input['name'])) {
         $this->name = $input['name'];
     }
 }
Ejemplo n.º 3
0
 public function testShowID()
 {
     $newline = PHP_SAPI == 'cli' ? "\n" : "<br/>";
     $expected = self::$l->getID() . " | parent: NULL" . $newline;
     $this->assertEquals($expected, self::$l->showID());
 }
Ejemplo n.º 4
0
 /**
  * Constructs object
  * @param Array|array $input
  */
 public function __construct(array $input = [])
 {
     parent::__construct($input);
 }