You are here

class TextToken in Search API 8

Represents a single text token contained in a fulltext field's value.

Hierarchy

Expanded class hierarchy of TextToken

See also

\Drupal\search_api\Plugin\search_api\data_type\value\TextValueInterface

4 files declare their use of TextToken
BackendTest.php in modules/search_api_db/tests/src/Kernel/BackendTest.php
Database.php in modules/search_api_db/src/Plugin/search_api/backend/Database.php
FieldsProcessorPluginBaseTest.php in tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php
Utility.php in src/Utility/Utility.php

File

src/Plugin/search_api/data_type/value/TextToken.php, line 10

Namespace

Drupal\search_api\Plugin\search_api\data_type\value
View source
class TextToken implements TextTokenInterface {

  /**
   * The actual text value of this token.
   *
   * @var string
   */
  protected $text;

  /**
   * The boost value for this token.
   *
   * @var float
   */
  protected $boost = 1.0;

  /**
   * Constructs a TextToken object.
   *
   * @param string $text
   *   The text value of the token.
   * @param float $boost
   *   (optional) The boost for the token.
   */
  public function __construct($text, $boost = 1.0) {
    $this->text = $text;
    $this->boost = $boost;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setText($text) {
    $this->text = $text;
    return $this;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setBoost($boost) {
    $this->boost = $boost;
    return $this;
  }

  /**
   * Implements the magic __toString() method.
   */
  public function __toString() {
    return $this
      ->getText();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TextToken::$boost protected property The boost value for this token.
TextToken::$text protected property The actual text value of this token.
TextToken::getBoost public function Retrieves the boost for this token. Overrides TextTokenInterface::getBoost
TextToken::getText public function Retrieves the text value of this token. Overrides TextTokenInterface::getText
TextToken::setBoost public function Sets the boost for this token. Overrides TextTokenInterface::setBoost
TextToken::setText public function Sets the text value of this token. Overrides TextTokenInterface::setText
TextToken::__construct public function Constructs a TextToken object.
TextToken::__toString public function Implements the magic __toString() method.