3 namespace Drupal\Component\Render;
5 use Drupal\Component\Utility\Html;
6 use Drupal\Component\Utility\Unicode;
9 * Escapes HTML syntax characters to HTML entities for display in markup.
11 * This class can be used to provide theme engine-like late escaping
14 * @ingroup sanitization
16 class HtmlEscapedText implements MarkupInterface, \Countable {
19 * The string to escape.
26 * Constructs an HtmlEscapedText object.
29 * The string to escape. This value will be cast to a string.
31 public function __construct($string) {
32 $this->string = (string) $string;
38 public function __toString() {
39 return Html::escape($this->string);
45 public function count() {
46 return Unicode::strlen($this->string);
52 public function jsonSerialize() {
53 return $this->__toString();