3 namespace Drupal\Component\Render;
5 use Drupal\Component\Utility\Html;
8 * Escapes HTML syntax characters to HTML entities for display in markup.
10 * This class can be used to provide theme engine-like late escaping
13 * @ingroup sanitization
15 class HtmlEscapedText implements MarkupInterface, \Countable {
18 * The string to escape.
25 * Constructs an HtmlEscapedText object.
28 * The string to escape. This value will be cast to a string.
30 public function __construct($string) {
31 $this->string = (string) $string;
37 public function __toString() {
38 return Html::escape($this->string);
44 public function count() {
45 return mb_strlen($this->string);
51 public function jsonSerialize() {
52 return $this->__toString();