<?php
 class vB_Utility_Template_ParserNode_Curly_Url extends vB_Utility_Template_ParserNode_Curly { public function validate() : array { $errors = []; $attributecount = sizeof($this->main_node->attributes); if ($attributecount == 0) { $errors[] = 'no_type_specified'; } if ($attributecount > 4) { $errors[] = 'too_many_attributes'; } foreach ($this->main_node->attributes AS $attribute) { if ($attribute instanceof vB_CurlyNode AND !in_array($attribute->value, ['raw', 'var'])) { $errors[] = 'url_only_accepts_vars'; } } return $errors; } public function compile() : string { $arguments = []; foreach ($this->main_node->attributes AS $attribute) { if ($attribute instanceof vB_CurlyNode) { $arguments[] = $this->attributeToString($attribute); } else if ($attribute === NULL) { $arguments[] = 'NULL'; } else if (is_numeric($attribute)) { $arguments[] = $attribute; } else { $arguments[] = "'" . $attribute . "'"; } } $arguments = implode(', ', $arguments); return 'vB_Template_Runtime::vBVar(vB_Template_Runtime::buildUrl(' . $arguments . '))'; } } 