Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
   4  
   5  use PhpOffice\PhpSpreadsheet\Calculation\Functions;
   6  
   7  class Text
   8  {
   9      /**
  10       * LEN.
  11       *
  12       * @param mixed $value String Value
  13       */
  14      public static function length($value = ''): int
  15      {
  16          $value = Helpers::extractString($value);
  17  
  18          return mb_strlen($value ?? '', 'UTF-8');
  19      }
  20  
  21      /**
  22       * Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise.
  23       * EXACT is case-sensitive but ignores formatting differences.
  24       * Use EXACT to test text being entered into a document.
  25       *
  26       * @param mixed $value1 String Value
  27       * @param mixed $value2 String Value
  28       */
  29      public static function exact($value1, $value2): bool
  30      {
  31          $value1 = Helpers::extractString($value1);
  32          $value2 = Helpers::extractString($value2);
  33  
  34          return $value2 === $value1;
  35      }
  36  
  37      /**
  38       * RETURNSTRING.
  39       *
  40       * @param mixed $testValue Value to check
  41       *
  42       * @return null|string
  43       */
  44      public static function test($testValue = '')
  45      {
  46          $testValue = Functions::flattenSingleValue($testValue);
  47  
  48          if (is_string($testValue)) {
  49              return $testValue;
  50          }
  51  
  52          return null;
  53      }
  54  }