vendor/presta/sitemap-bundle/src/Sitemap/Utils.php line 40

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the PrestaSitemapBundle package.
  4. *
  5. * (c) PrestaConcept <https://prestaconcept.net>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Presta\SitemapBundle\Sitemap;
  11. /**
  12. * XML utils for sitemap format.
  13. */
  14. class Utils
  15. {
  16. /**
  17. * Wrap string with CDATA markup
  18. *
  19. * @param string|null $string
  20. *
  21. * @return string
  22. */
  23. public static function cdata(?string $string): string
  24. {
  25. return '<![CDATA[' . $string . ']]>';
  26. }
  27. /**
  28. * Encode string with html special chars
  29. *
  30. * @param string $string
  31. *
  32. * @return string
  33. */
  34. public static function encode(string $string): string
  35. {
  36. return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
  37. }
  38. }