コード例 #1
0
ファイル: NodeTest.php プロジェクト: rodenas2u/lol
 public function testSetValue()
 {
     $node = new Node();
     $node->setValue('string value');
     $this->assertEquals('string value', $node->getValue());
     $node->setValue($object = new \stdClass());
     $object->foo = 'bar';
     $this->assertEquals($object, $node->getValue());
 }
コード例 #2
0
 /**
  * Recursively build chart of account tree
  *
  * @param Node $tree
  * @param \DOMNode $node
  * @param Chart $chart
  * @param array $accountTypes
  */
 protected function buildTree(Node $tree, \DOMNode $node, Chart $chart, array $accountTypes)
 {
     //create current node
     list($nominal, $type, $name) = FFor::create()->attributes(function () use($node) {
         return $node->attributes;
     })->nominal(function ($attributes) {
         return new Nominal($attributes->getNamedItem('nominal')->nodeValue);
     })->name(function ($attributes) {
         return new StringType($attributes->getNamedItem('name')->nodeValue);
     })->type(function ($attributes) use($accountTypes) {
         return new AccountType($accountTypes[strtoupper($attributes->getNamedItem('type')->nodeValue)]);
     })->fyield('nominal', 'type', 'name');
     $tree->setValue(new Account($chart, $nominal, $type, $name));
     //recurse through sub accounts
     foreach ($node->childNodes as $childNode) {
         if ($childNode instanceof \DOMElement) {
             $childTree = new Node();
             $tree->addChild($childTree);
             $this->buildTree($childTree, $childNode, $chart, $accountTypes);
         }
     }
 }