Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
   4  
   5  use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
   6  
   7  class Trim
   8  {
   9      use ArrayEnabled;
  10  
  11      /**
  12       * CLEAN.
  13       *
  14       * @param mixed $stringValue String Value to check
  15       *                              Or can be an array of values
  16       *
  17       * @return array|string
  18       *         If an array of values is passed as the argument, then the returned result will also be an array
  19       *            with the same dimensions
  20       */
  21      public static function nonPrintable($stringValue = '')
  22      {
  23          if (is_array($stringValue)) {
  24              return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $stringValue);
  25          }
  26  
  27          $stringValue = Helpers::extractString($stringValue);
  28  
  29          return (string) preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
  30      }
  31  
  32      /**
  33       * TRIM.
  34       *
  35       * @param mixed $stringValue String Value to check
  36       *                              Or can be an array of values
  37       *
  38       * @return array|string
  39       *         If an array of values is passed as the argument, then the returned result will also be an array
  40       *            with the same dimensions
  41       */
  42      public static function spaces($stringValue = '')
  43      {
  44          if (is_array($stringValue)) {
  45              return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $stringValue);
  46          }
  47  
  48          $stringValue = Helpers::extractString($stringValue);
  49  
  50          return trim(preg_replace('/ +/', ' ', trim("$stringValue", ' ')) ?? '', ' ');
  51      }
  52  }