public function evaluate()
{
$allowEmpty = $this->getAllowEmpty();
$renderedAttributes = '';
foreach (array_keys($this->properties) as $attributeName) {
if ($attributeName === '__meta' || in_array($attributeName, $this->ignoreProperties)) {
continue;
}
$encodedAttributeName = htmlspecialchars($attributeName, ENT_COMPAT, 'UTF-8', false);
$attributeValue = $this->tsValue($attributeName);
if ($attributeValue === null || $attributeValue === false) {
// No op
} elseif ($attributeValue === true || $attributeValue === '') {
$renderedAttributes .= ' ' . $encodedAttributeName . ($allowEmpty ? '' : '=""');
} else {
if (is_array($attributeValue)) {
$joinedAttributeValue = '';
foreach ($attributeValue as $attributeValuePart) {
if ((string) $attributeValuePart !== '') {
$joinedAttributeValue .= ' ' . trim($attributeValuePart);
}
}
$attributeValue = trim($joinedAttributeValue);
}
$encodedAttributeValue = htmlspecialchars($attributeValue, ENT_COMPAT, 'UTF-8', false);
$renderedAttributes .= ' ' . $encodedAttributeName . '="' . $encodedAttributeValue . '"';
}
}
return $renderedAttributes;
}