Code Duplication    Length = 6-6 lines in 3 locations

src/PhpSpreadsheet/Calculation/Calculation.php 3 locations

@@ 3133-3138 (lines=6) @@
3130
                $expectingOperator = false;
3131
            } elseif ($opCharacter == ')' && $expectingOperator) {            //    Are we expecting to close a parenthesis?
3132
                $expectingOperand = false;
3133
                while (($o2 = $stack->pop()) && $o2['value'] != '(') {        //    Pop off the stack back to the last (
3134
                    if ($o2 === null) {
3135
                        return $this->raiseFormulaError('Formula Error: Unexpected closing brace ")"');
3136
                    }
3137
                    $output[] = $o2;
3138
                }
3139
                $d = $stack->last(2);
3140
                if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) {    //    Did this parenthesis just close a function?
3141
                    $functionName = $matches[1]; //    Get the function name
@@ 3201-3206 (lines=6) @@
3198
                }
3199
                ++$index;
3200
            } elseif ($opCharacter == ',') {            //    Is this the separator for function arguments?
3201
                while (($o2 = $stack->pop()) && $o2['value'] != '(') {        //    Pop off the stack back to the last (
3202
                    if ($o2 === null) {
3203
                        return $this->raiseFormulaError('Formula Error: Unexpected ,');
3204
                    }
3205
                    $output[] = $o2; // pop the argument expression stuff and push onto the output
3206
                }
3207
                //    If we've a comma when we're expecting an operand, then what we actually have is a null operand;
3208
                //        so push a null onto the stack
3209
                if (($expectingOperand) || (!$expectingOperator)) {
@@ 3376-3381 (lines=6) @@
3373
            }
3374
        }
3375
3376
        while (($op = $stack->pop()) !== null) {    // pop everything off the stack and push onto output
3377
            if ((is_array($op) && $op['value'] == '(') || ($op === '(')) {
3378
                return $this->raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced
3379
            }
3380
            $output[] = $op;
3381
        }
3382
3383
        return $output;
3384
    }