You are here

private function PHPExcel_Calculation::_validateBinaryOperand in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php \PHPExcel_Calculation::_validateBinaryOperand()
1 call to PHPExcel_Calculation::_validateBinaryOperand()
PHPExcel_Calculation::_executeNumericBinaryOperation in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php, line 3498

Class

PHPExcel_Calculation
PHPExcel_Calculation (Multiton)

Code

private function _validateBinaryOperand($cellID, &$operand, &$stack) {
  if (is_array($operand)) {
    if (count($operand, COUNT_RECURSIVE) - count($operand) == 1) {
      do {
        $operand = array_pop($operand);
      } while (is_array($operand));
    }
  }

  //	Numbers, matrices and booleans can pass straight through, as they're already valid
  if (is_string($operand)) {

    //	We only need special validations for the operand if it is a string
    //	Start by stripping off the quotation marks we use to identify true excel string values internally
    if ($operand > '' && $operand[0] == '"') {
      $operand = self::_unwrapResult($operand);
    }

    //	If the string is a numeric value, we treat it as a numeric, so no further testing
    if (!is_numeric($operand)) {

      //	If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
      if ($operand > '' && $operand[0] == '#') {
        $stack
          ->push('Value', $operand);
        $this->_debugLog
          ->writeDebugLog('Evaluation Result is ', $this
          ->_showTypeDetails($operand));
        return FALSE;
      }
      elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) {

        //	If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations
        $stack
          ->push('Value', '#VALUE!');
        $this->_debugLog
          ->writeDebugLog('Evaluation Result is a ', $this
          ->_showTypeDetails('#VALUE!'));
        return FALSE;
      }
    }
  }

  //	return a true if the value of the operand is one that we can use in normal binary operations
  return TRUE;
}