/** * Render a single HTML element * * @param string $element HTML element name * @param mixed $content Content to be enclosed within tags, NULL for elements without content * @param array $attributes Associative array of attributes for the element. Values are escaped automatically. * @param bool $inline Whether the element should appear inline or with newlines * @return string */ function __invoke($element, $content = null, $attributes = null, $inline = false) { $newline = $inline ? '' : "\n"; // opening tag $output = "<{$element}"; if (is_array($attributes)) { foreach ($attributes as $attribute => $value) { $output .= " {$attribute}=\"" . $this->_escapeHtmlAttr->__invoke($value) . '"'; } } if ($content === null) { if ($this->_emptyTags) { // HTML if (in_array(strtolower($element), $this->_emptyTags)) { $output .= '>'; } else { $output .= "></{$element}>"; } } else { // XHTML $output .= ' />'; } $output .= $newline; return $output; } $output .= '>'; $output .= $newline; // content $output .= $content; $output .= $newline; // closing tag $output .= "</{$element}>"; $output .= $newline; return $output; }
public function testSettingValidEncodingShouldNotThrowExceptions() { foreach ($this->supportedEncodings as $value) { $helper = new EscapeHelper(); $helper->setEncoding($value); $helper->getEscaper(); } }