<?php
 class vB_Utility_Template_ParserNode_Curly_If extends vB_Utility_Template_ParserNode_Curly { public function validate() : array { $errors = []; $attributecount = sizeof($this->main_node->attributes); if ($attributecount == 0) { $errors[] = 'no_condition_specified'; } if ($attributecount == 1) { $errors[] = 'no_true_expression_specified'; } if ($attributecount > 3) { $errors[] = 'too_many_attributes'; } $conditionerrors = $this->validateCondition($this->main_node->attributes[0]); if ($conditionerrors) { $errors = array_merge($conditionerrors); } return $errors; } public function compile() : string { $trueval = $this->attributeToString($this->main_node->attributes[1]); if (isset($this->main_node->attributes[2])) { $falseval = $this->attributeToString($this->main_node->attributes[2]); } else { $falseval = '""'; } return '((' . $this->main_node->attributes[0] . ') ? ' . $trueval . ' : ' . $falseval . ') '; } } 