Exemple #1
0
 /**
  * Parse the passed transform JSON objects into transform nodes
  *
  * @param  object $t A transform object from within the spec JSON
  * @return Node[]
  */
 protected function parseTransform($t)
 {
     $nodes = [];
     // Determine if we're dealing with an array or an object
     if (is_object($t)) {
         // Iterate the object props ...
         foreach ($t as $key => $val) {
             // ... determining their selector type
             $tSelector = SelectorFactory::create($key, $this->options);
             $node = new Node($tSelector);
             // ... and values
             if (is_object($val)) {
                 // If it's an object, we need to recurse down another level
                 $node->setChildNodes($this->parseTransform($val));
             } else {
                 // If not an object, we should apply a value modifier
                 $valModifier = ModifierFactory::create($val, $this->options);
                 $node->setValueModifier($valModifier);
             }
             $nodes[] = $node;
         }
     }
     return $nodes;
 }
Exemple #2
0
 public function testChildNodes()
 {
     $childNodes = [new Node(new ByValueSelector("a")), new Node(new ByValueSelector("b"))];
     $this->node->setChildNodes($childNodes);
     $this->assertSame($childNodes, $this->node->getChildNodes());
 }