HtmlHelper.php 535 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace fphammerle\helpers;
  3. class HtmlHelper
  4. {
  5. public static function encode($string)
  6. {
  7. return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE);
  8. }
  9. public static function endTag($name)
  10. {
  11. if($name === null) {
  12. return null;
  13. } elseif(!is_string($name)) {
  14. throw new \TypeError(
  15. sprintf('expected string or null as name, %s given', gettype($name))
  16. );
  17. } else {
  18. return '</' . $name . '>';
  19. }
  20. }
  21. }