You are here

public static function TestExtension::testFunction in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php \Drupal\twig_extension_test\TwigExtension\TestExtension::testFunction()

Outputs either an uppercase or lowercase test phrase.

The function generates either an uppercase or lowercase version of the phrase "The quick brown fox jumps over the lazy dog 123.", depending on whether or not the $upperCase parameter evaluates to TRUE. If $upperCase evaluates to TRUE, the result will be uppercase, and if it evaluates to FALSE, the result will be lowercase.

Parameters

bool $upperCase: (optional) Whether the result is uppercase (true) or lowercase (false).

Return value

string The generated string.

See also

\Drupal\system\Tests\Theme\TwigExtensionTest::testTwigExtensionFunction()

File

core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php, line 80
Contains \Drupal\twig_extension_test\TwigExtension\TestExtension.

Class

TestExtension
A test Twig extension that adds a custom function and a custom filter.

Namespace

Drupal\twig_extension_test\TwigExtension

Code

public static function testFunction($upperCase = FALSE) {
  $string = "The quick brown box jumps over the lazy dog 123.";
  if ($upperCase == TRUE) {
    return strtoupper($string);
  }
  else {
    return strtolower($string);
  }
}