You are here

TextElement.php in Extensible BBCode 4.0.x

Same filename and directory in other branches
  1. 8.3 src/Parser/Tree/TextElement.php

File

src/Parser/Tree/TextElement.php
View source
<?php

namespace Drupal\xbbcode\Parser\Tree;


/**
 * An element representing a text fragment.
 */
class TextElement implements ElementInterface {

  /**
   * The text.
   *
   * @var string
   */
  protected $text;

  /**
   * TextElement constructor.
   *
   * @param string $text
   *   The text.
   */
  public function __construct(string $text) {
    $this
      ->setText($text);
  }

  /**
   * Get the text.
   *
   * @return string
   *   The text.
   */
  public function getText() : string {
    return $this->text;
  }

  /**
   * Set the text.
   *
   * @param string $text
   *   The text.
   *
   * @return $this
   */
  public function setText(string $text) : self {
    $this->text = $text;
    return $this;
  }

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

}

Classes

Namesort descending Description
TextElement An element representing a text fragment.