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.
   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation\Information;
   4  
   5  use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
   6  
   7  class ErrorValue
   8  {
   9      use ArrayEnabled;
  10  
  11      /**
  12       * IS_ERR.
  13       *
  14       * @param mixed $value Value to check
  15       *                      Or can be an array of values
  16       *
  17       * @return array|bool
  18       *         If an array of numbers is passed as an argument, then the returned result will also be an array
  19       *            with the same dimensions
  20       */
  21      public static function isErr($value = '')
  22      {
  23          if (is_array($value)) {
  24              return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value);
  25          }
  26  
  27          return self::isError($value) && (!self::isNa(($value)));
  28      }
  29  
  30      /**
  31       * IS_ERROR.
  32       *
  33       * @param mixed $value Value to check
  34       *                      Or can be an array of values
  35       *
  36       * @return array|bool
  37       *         If an array of numbers is passed as an argument, then the returned result will also be an array
  38       *            with the same dimensions
  39       */
  40      public static function isError($value = '')
  41      {
  42          if (is_array($value)) {
  43              return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value);
  44          }
  45  
  46          if (!is_string($value)) {
  47              return false;
  48          }
  49  
  50          return in_array($value, ExcelError::ERROR_CODES, true);
  51      }
  52  
  53      /**
  54       * IS_NA.
  55       *
  56       * @param mixed $value Value to check
  57       *                      Or can be an array of values
  58       *
  59       * @return array|bool
  60       *         If an array of numbers is passed as an argument, then the returned result will also be an array
  61       *            with the same dimensions
  62       */
  63      public static function isNa($value = '')
  64      {
  65          if (is_array($value)) {
  66              return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value);
  67          }
  68  
  69          return $value === ExcelError::NA();
  70      }
  71  }