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 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation;
   4  
   5  use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean;
   6  
   7  /**
   8   * @deprecated 1.17.0
   9   */
  10  class Logical
  11  {
  12      /**
  13       * TRUE.
  14       *
  15       * Returns the boolean TRUE.
  16       *
  17       * Excel Function:
  18       *        =TRUE()
  19       *
  20       * @Deprecated 1.17.0
  21       *
  22       * @see Logical\Boolean::TRUE()
  23       * Use the TRUE() method in the Logical\Boolean class instead
  24       *
  25       * @return bool True
  26       */
  27      public static function true(): bool
  28      {
  29          return Boolean::true();
  30      }
  31  
  32      /**
  33       * FALSE.
  34       *
  35       * Returns the boolean FALSE.
  36       *
  37       * Excel Function:
  38       *        =FALSE()
  39       *
  40       * @Deprecated 1.17.0
  41       *
  42       * @see Logical\Boolean::FALSE()
  43       * Use the FALSE() method in the Logical\Boolean class instead
  44       *
  45       * @return bool False
  46       */
  47      public static function false(): bool
  48      {
  49          return Boolean::false();
  50      }
  51  
  52      /**
  53       * LOGICAL_AND.
  54       *
  55       * Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
  56       *
  57       * Excel Function:
  58       *        =AND(logical1[,logical2[, ...]])
  59       *
  60       *        The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
  61       *            or references that contain logical values.
  62       *
  63       *        Boolean arguments are treated as True or False as appropriate
  64       *        Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
  65       *        If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
  66       *            holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
  67       *
  68       * @Deprecated 1.17.0
  69       *
  70       * @see Logical\Operations::logicalAnd()
  71       * Use the logicalAnd() method in the Logical\Operations class instead
  72       *
  73       * @param mixed ...$args Data values
  74       *
  75       * @return bool|string the logical AND of the arguments
  76       */
  77      public static function logicalAnd(...$args)
  78      {
  79          return Logical\Operations::logicalAnd(...$args);
  80      }
  81  
  82      /**
  83       * LOGICAL_OR.
  84       *
  85       * Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
  86       *
  87       * Excel Function:
  88       *        =OR(logical1[,logical2[, ...]])
  89       *
  90       *        The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
  91       *            or references that contain logical values.
  92       *
  93       *        Boolean arguments are treated as True or False as appropriate
  94       *        Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
  95       *        If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
  96       *            holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
  97       *
  98       * @Deprecated 1.17.0
  99       *
 100       * @see Logical\Operations::logicalOr()
 101       * Use the logicalOr() method in the Logical\Operations class instead
 102       *
 103       * @param mixed $args Data values
 104       *
 105       * @return bool|string the logical OR of the arguments
 106       */
 107      public static function logicalOr(...$args)
 108      {
 109          return Logical\Operations::logicalOr(...$args);
 110      }
 111  
 112      /**
 113       * LOGICAL_XOR.
 114       *
 115       * Returns the Exclusive Or logical operation for one or more supplied conditions.
 116       * i.e. the Xor function returns TRUE if an odd number of the supplied conditions evaluate to TRUE,
 117       *      and FALSE otherwise.
 118       *
 119       * Excel Function:
 120       *        =XOR(logical1[,logical2[, ...]])
 121       *
 122       *        The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
 123       *            or references that contain logical values.
 124       *
 125       *        Boolean arguments are treated as True or False as appropriate
 126       *        Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
 127       *        If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
 128       *            holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
 129       *
 130       * @Deprecated 1.17.0
 131       *
 132       * @see Logical\Operations::logicalXor()
 133       * Use the logicalXor() method in the Logical\Operations class instead
 134       *
 135       * @param mixed $args Data values
 136       *
 137       * @return bool|string the logical XOR of the arguments
 138       */
 139      public static function logicalXor(...$args)
 140      {
 141          return Logical\Operations::logicalXor(...$args);
 142      }
 143  
 144      /**
 145       * NOT.
 146       *
 147       * Returns the boolean inverse of the argument.
 148       *
 149       * Excel Function:
 150       *        =NOT(logical)
 151       *
 152       *        The argument must evaluate to a logical value such as TRUE or FALSE
 153       *
 154       *        Boolean arguments are treated as True or False as appropriate
 155       *        Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
 156       *        If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
 157       *            holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
 158       *
 159       * @Deprecated 1.17.0
 160       *
 161       * @see Logical\Operations::NOT()
 162       * Use the NOT() method in the Logical\Operations class instead
 163       *
 164       * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
 165       *
 166       * @return array|bool|string the boolean inverse of the argument
 167       */
 168      public static function NOT($logical = false)
 169      {
 170          return Logical\Operations::NOT($logical);
 171      }
 172  
 173      /**
 174       * STATEMENT_IF.
 175       *
 176       * Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
 177       *
 178       * Excel Function:
 179       *        =IF(condition[,returnIfTrue[,returnIfFalse]])
 180       *
 181       *        Condition is any value or expression that can be evaluated to TRUE or FALSE.
 182       *            For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
 183       *            the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
 184       *            This argument can use any comparison calculation operator.
 185       *        ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
 186       *            For example, if this argument is the text string "Within budget" and the condition argument
 187       *                evaluates to TRUE, then the IF function returns the text "Within budget"
 188       *            If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero).
 189       *               To display the word TRUE, use the logical value TRUE for this argument.
 190       *            ReturnIfTrue can be another formula.
 191       *        ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
 192       *            For example, if this argument is the text string "Over budget" and the condition argument
 193       *                evaluates to FALSE, then the IF function returns the text "Over budget".
 194       *            If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
 195       *            If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
 196       *            ReturnIfFalse can be another formula.
 197       *
 198       * @Deprecated 1.17.0
 199       *
 200       * @see Logical\Conditional::statementIf()
 201       * Use the statementIf() method in the Logical\Conditional class instead
 202       *
 203       * @param mixed $condition Condition to evaluate
 204       * @param mixed $returnIfTrue Value to return when condition is true
 205       * @param mixed $returnIfFalse Optional value to return when condition is false
 206       *
 207       * @return mixed The value of returnIfTrue or returnIfFalse determined by condition
 208       */
 209      public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
 210      {
 211          return Logical\Conditional::statementIf($condition, $returnIfTrue, $returnIfFalse);
 212      }
 213  
 214      /**
 215       * STATEMENT_SWITCH.
 216       *
 217       * Returns corresponding with first match (any data type such as a string, numeric, date, etc).
 218       *
 219       * Excel Function:
 220       *        =SWITCH (expression, value1, result1, value2, result2, ... value_n, result_n [, default])
 221       *
 222       *        Expression
 223       *              The expression to compare to a list of values.
 224       *        value1, value2, ... value_n
 225       *              A list of values that are compared to expression.
 226       *              The SWITCH function is looking for the first value that matches the expression.
 227       *        result1, result2, ... result_n
 228       *              A list of results. The SWITCH function returns the corresponding result when a value
 229       *              matches expression.
 230       *         default
 231       *              Optional. It is the default to return if expression does not match any of the values
 232       *              (value1, value2, ... value_n).
 233       *
 234       * @Deprecated 1.17.0
 235       *
 236       * @see Logical\Conditional::statementSwitch()
 237       * Use the statementSwitch() method in the Logical\Conditional class instead
 238       *
 239       * @param mixed $arguments Statement arguments
 240       *
 241       * @return mixed The value of matched expression
 242       */
 243      public static function statementSwitch(...$arguments)
 244      {
 245          return Logical\Conditional::statementSwitch(...$arguments);
 246      }
 247  
 248      /**
 249       * IFERROR.
 250       *
 251       * Excel Function:
 252       *        =IFERROR(testValue,errorpart)
 253       *
 254       * @Deprecated 1.17.0
 255       *
 256       * @see Logical\Conditional::IFERROR()
 257       * Use the IFERROR() method in the Logical\Conditional class instead
 258       *
 259       * @param mixed $testValue Value to check, is also the value returned when no error
 260       * @param mixed $errorpart Value to return when testValue is an error condition
 261       *
 262       * @return mixed The value of errorpart or testValue determined by error condition
 263       */
 264      public static function IFERROR($testValue = '', $errorpart = '')
 265      {
 266          return Logical\Conditional::IFERROR($testValue, $errorpart);
 267      }
 268  
 269      /**
 270       * IFNA.
 271       *
 272       * Excel Function:
 273       *        =IFNA(testValue,napart)
 274       *
 275       * @Deprecated 1.17.0
 276       *
 277       * @see Logical\Conditional::IFNA()
 278       * Use the IFNA() method in the Logical\Conditional class instead
 279       *
 280       * @param mixed $testValue Value to check, is also the value returned when not an NA
 281       * @param mixed $napart Value to return when testValue is an NA condition
 282       *
 283       * @return mixed The value of errorpart or testValue determined by error condition
 284       */
 285      public static function IFNA($testValue = '', $napart = '')
 286      {
 287          return Logical\Conditional::IFNA($testValue, $napart);
 288      }
 289  
 290      /**
 291       * IFS.
 292       *
 293       * Excel Function:
 294       *         =IFS(testValue1;returnIfTrue1;testValue2;returnIfTrue2;...;testValue_n;returnIfTrue_n)
 295       *
 296       *         testValue1 ... testValue_n
 297       *             Conditions to Evaluate
 298       *         returnIfTrue1 ... returnIfTrue_n
 299       *             Value returned if corresponding testValue (nth) was true
 300       *
 301       * @Deprecated 1.17.0
 302       *
 303       * @see Logical\Conditional::IFS()
 304       * Use the IFS() method in the Logical\Conditional class instead
 305       *
 306       * @param mixed ...$arguments Statement arguments
 307       *
 308       * @return mixed|string The value of returnIfTrue_n, if testValue_n was true. #N/A if none of testValues was true
 309       */
 310      public static function IFS(...$arguments)
 311      {
 312          return Logical\Conditional::IFS(...$arguments);
 313      }
 314  }