From 20d007abb1a669466f769bbc1d14dff883102270 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 19 May 2016 12:49:15 +0200 Subject: [PATCH] #401 : PHPUnit Fixes (Calculation > Engineering) --- .../Calculation/Engineering.php | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index e042f6c3..b3305464 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -772,11 +772,10 @@ class Engineering $realNumber = substr($workString, 0, strlen($realNumber) + strlen($power) + $leadingSign); - //if ($suffix != '') { + if ($suffix != '') { $imaginary = substr($workString, strlen($realNumber)); - if ($imaginary == false) { - $imaginary = ''; - } elseif (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) { + + if (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) { $imaginary = $realNumber . '1'; $realNumber = '0'; } elseif ($imaginary == '') { @@ -785,7 +784,7 @@ class Engineering } elseif (($imaginary == '+') || ($imaginary == '-')) { $imaginary .= '1'; } - //} + } return array( 'real' => $realNumber, @@ -2192,12 +2191,9 @@ class Engineering $parsedComplexDividend = self::parseComplex($complexDividend); $parsedComplexDivisor = self::parseComplex($complexDivisor); - if (($parsedComplexDividend['suffix'] != '' && $parsedComplexDivisor['suffix'] != '') && ($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) { - return Functions::NAN(); - } - if ((($parsedComplexDividend['suffix'] != '' && $parsedComplexDivisor['imaginary'] != '') - || ($parsedComplexDivisor['suffix'] != '' && $parsedComplexDividend['imaginary'] != '')) - && ($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) { + if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') && + ($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix']) + ) { return Functions::NAN(); } if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) { @@ -2245,13 +2241,7 @@ class Engineering ($parsedComplex1['suffix'] != $parsedComplex2['suffix']) ) { return Functions::NAN(); - } - if ((($parsedComplex1['suffix'] != '' && $parsedComplex2['imaginary'] != '') - || ($parsedComplex2['suffix'] != '' && $parsedComplex1['imaginary'] != '')) - && ($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) { - return Functions::NAN(); - } - if (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) { + } elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) { $parsedComplex1['suffix'] = $parsedComplex2['suffix']; }