ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Logical.php
Go to the documentation of this file.
1 <?php
30 if (!defined('PHPEXCEL_ROOT')) {
34  define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
35  require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
36 }
37 
38 
47 
60  public static function TRUE() {
61  return TRUE;
62  } // function TRUE()
63 
64 
77  public static function FALSE() {
78  return FALSE;
79  } // function FALSE()
80 
81 
103  public static function LOGICAL_AND() {
104  // Return value
105  $returnValue = TRUE;
106 
107  // Loop through the arguments
108  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
109  $argCount = -1;
110  foreach ($aArgs as $argCount => $arg) {
111  // Is it a boolean value?
112  if (is_bool($arg)) {
113  $returnValue = $returnValue && $arg;
114  } elseif ((is_numeric($arg)) && (!is_string($arg))) {
115  $returnValue = $returnValue && ($arg != 0);
116  } elseif (is_string($arg)) {
117  $arg = strtoupper($arg);
118  if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
119  $arg = TRUE;
120  } elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
121  $arg = FALSE;
122  } else {
124  }
125  $returnValue = $returnValue && ($arg != 0);
126  }
127  }
128 
129  // Return
130  if ($argCount < 0) {
132  }
133  return $returnValue;
134  } // function LOGICAL_AND()
135 
136 
158  public static function LOGICAL_OR() {
159  // Return value
160  $returnValue = FALSE;
161 
162  // Loop through the arguments
163  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
164  $argCount = -1;
165  foreach ($aArgs as $argCount => $arg) {
166  // Is it a boolean value?
167  if (is_bool($arg)) {
168  $returnValue = $returnValue || $arg;
169  } elseif ((is_numeric($arg)) && (!is_string($arg))) {
170  $returnValue = $returnValue || ($arg != 0);
171  } elseif (is_string($arg)) {
172  $arg = strtoupper($arg);
173  if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
174  $arg = TRUE;
175  } elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
176  $arg = FALSE;
177  } else {
179  }
180  $returnValue = $returnValue || ($arg != 0);
181  }
182  }
183 
184  // Return
185  if ($argCount < 0) {
187  }
188  return $returnValue;
189  } // function LOGICAL_OR()
190 
191 
212  public static function NOT($logical=FALSE) {
214  if (is_string($logical)) {
215  $logical = strtoupper($logical);
216  if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
217  return FALSE;
218  } elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
219  return TRUE;
220  } else {
222  }
223  }
224 
225  return !$logical;
226  } // function NOT()
227 
260  public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
261  $condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
262  $returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
263  $returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
264 
265  return ($condition) ? $returnIfTrue : $returnIfFalse;
266  } // function STATEMENT_IF()
267 
268 
281  public static function IFERROR($testValue = '', $errorpart = '') {
282  $testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
283  $errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
284 
285  return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
286  } // function IFERROR()
287 
288 } // class PHPExcel_Calculation_Logical
static getTRUE()
Return the locale-specific translation of TRUE.
static IS_ERROR($value='')
IS_ERROR.
Definition: Functions.php:384
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
Definition: Functions.php:662
static IFERROR($testValue='', $errorpart='')
Definition: Logical.php:281
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
Definition: Functions.php:598
static getFALSE()
Return the locale-specific translation of FALSE.
static STATEMENT_IF($condition=TRUE, $returnIfTrue=0, $returnIfFalse=FALSE)
Definition: Logical.php:260
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
static NOT($logical=FALSE)
Definition: Logical.php:212