/** * 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; }
public function testValueModifier() { $valueModifier = new SimpleReplaceModifier("new value"); $this->node->setValueModifier($valueModifier); $this->assertSame($valueModifier, $this->node->getValueModifier()); }