You are here

GoogleAnalyticsJavaScriptSnippet.php in Google Analytics 8.2

File

src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php
View source
<?php

namespace Drupal\google_analytics\Component\Render;

use Drupal\Component\Render\MarkupInterface;

/**
 * Formats a string for JavaScript display.
 */
class GoogleAnalyticsJavaScriptSnippet implements MarkupInterface {

  /**
   * The string to escape.
   *
   * @var string
   */
  protected $string;

  /**
   * Constructs an HtmlEscapedText object.
   *
   * @param string $string
   *   The string to escape. This value will be cast to a string.
   */
  public function __construct($string) {
    $this->string = (string) $string;
  }

  /**
   * {@inheritdoc}
   */
  public function __toString() {
    return $this->string;
  }

  /**
   * {@inheritdoc}
   */
  public function jsonSerialize() {
    return $this
      ->__toString();
  }

}

Classes

Namesort descending Description
GoogleAnalyticsJavaScriptSnippet Formats a string for JavaScript display.