/** * Visit optional sub expression * * The return type of this method varies deping on the concrete visitor * implementation * * @param slRegularExpressionOptional $regularExpression * @return mixed */ protected function visitOptional(slRegularExpressionOptional $regularExpression) { return $this->visit($regularExpression->getChild()) . '?'; }
/** * Visit optional sub expression * * The return type of this method varies deping on the concrete visitor * implementation * * @param slRegularExpressionOptional $regularExpression * @return mixed */ protected function visitOptional(slRegularExpressionOptional $regularExpression) { $sequence = $this->document->createElementNS('http://www.w3.org/2001/XMLSchema', 'sequence'); $sequence->setAttribute('minOccurs', '0'); $sequence->setAttribute('maxOccurs', '1'); $sequence->appendChild($this->visit($regularExpression->getChild())); return $sequence; }
public function testSingularGetChildren() { $regexp = new slRegularExpressionOptional(new slRegularExpressionElement('a')); $regexp->setChild($c = new slRegularExpressionElement('b')); $this->assertSame(array($c), $regexp->getChildren()); }