You are here

public function Token::setDescription in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x modules/core_event_dispatcher/src/ValueObject/Token.php \Drupal\core_event_dispatcher\ValueObject\Token::setDescription()

Set description and return a new instance.

Parameters

string|\Drupal\Component\Render\MarkupInterface $description: The description of the token type.

Return value

\Drupal\core_event_dispatcher\ValueObject\Token New instance with the given description.

Throws

\UnexpectedValueException

File

modules/core_event_dispatcher/src/ValueObject/Token.php, line 90

Class

Token
Token ValueObject.

Namespace

Drupal\core_event_dispatcher\ValueObject

Code

public function setDescription($description) : self {
  if (!is_string($description) && !$description instanceof MarkupInterface) {
    throw new UnexpectedValueException('Description should be a string or an instance of MarkupInterface');
  }
  $clone = clone $this;
  $clone->description = $description;
  return $clone;
}