Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Token.php

function Token::test

Tests the current token for a type and/or a value.

Parameters may be:

  • just type
  • type and value (or array of possible values)
  • just value (or array of possible values) (NAME_TYPE is used as type)

Parameters

array|string|int $type The type to test:

array|string|null $values The token value:

File

vendor/twig/twig/src/Token.php, line 59

Class

Token
@author Fabien Potencier <fabien@symfony.com>

Namespace

Twig

Code

public function test($type, $values = null) : bool {
    if (null === $values && !\is_int($type)) {
        $values = $type;
        $type = self::NAME_TYPE;
    }
    return $this->type === $type && (null === $values || \is_array($values) && \in_array($this->value, $values) || $this->value == $values);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal