45 public function __construct(SimpleXMLElement $node, $parent)
47 $this->parent = $parent;
50 foreach ($node->children() as $child) {
51 switch ($child->getName()) {
53 $this->children->add(
"if",
new ChooseIf($child, $this));
59 $this->children->add(
"else",
new ChooseElse($child, $this));
63 if (!empty($elseIf)) {
64 $this->children->add(
"elseif", $elseIf);
73 public function render($data, $citationNumber =
null)
78 if ($prevCondition = $this->children->get(
"if")->match($data)) {
79 $arr[] = $this->children->get(
"if")->render($data);
80 } elseif (!$prevCondition && $this->children->hasKey(
"elseif")) {
84 foreach ($this->children->get(
"elseif") as $child) {
85 $condition = $child->match($data);
86 if ($condition && !$prevCondition) {
87 $arr[] = $child->render($data);
88 $prevCondition =
true;
91 $prevCondition = $condition;
96 if (!$prevCondition && $this->children->hasKey(
"else")) {
97 $arr[] = $this->children->get(
"else")->render($data);
99 return implode(
"", $arr);
107 return $this->parent;