You are here

class TextElement in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Parser/Tree/TextElement.php \Drupal\xbbcode\Parser\Tree\TextElement

An element representing a text fragment.

Hierarchy

Expanded class hierarchy of TextElement

3 files declare their use of TextElement
TreeEncodeTrait.php in standard/src/TreeEncodeTrait.php
XBBCodeFilter.php in src/Plugin/Filter/XBBCodeFilter.php
XBBCodeParser.php in src/Parser/XBBCodeParser.php

File

src/Parser/Tree/TextElement.php, line 8

Namespace

Drupal\xbbcode\Parser\Tree
View source
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();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TextElement::$text protected property The text.
TextElement::getText public function Get the text.
TextElement::render public function Render this element to a string. Overrides ElementInterface::render
TextElement::setText public function Set the text.
TextElement::__construct public function TextElement constructor.