/** * @param RepetitionNode $node * * @return string */ protected function printRepetitionNode(RepetitionNode $node) { if ($node->getMax() !== null) { $count = mt_rand($node->getMin(), $node->getMax()); } else { $count = mt_rand($node->getMin(), $node->getMin() + 5); } $output = ''; for ($i = 0; $i < $count; ++$i) { foreach ($node->getChildNodes() as $childNode) { $output .= $this->printNode($childNode); } } return $output; }
/** * @param RepetitionNode $node * * @return \DOMElement */ protected function formatRepetitionNode(RepetitionNode $node) { $xmlNode = $this->createXmlNode($node->getName()); $xmlNode->setAttribute('min', $node->getMin()); if ($node->getMax() !== null) { $xmlNode->setAttribute('max', $node->getMax()); } return $xmlNode; }