Code Duplication    Length = 36-37 lines in 2 locations

src/PhpSpreadsheet/Calculation/Statistical.php 2 locations

@@ 729-764 (lines=36) @@
726
     *
727
     * @return    float
728
     */
729
    public static function AVEDEV()
730
    {
731
        $aArgs = Functions::flattenArrayIndexed(func_get_args());
732
733
        // Return value
734
        $returnValue = null;
735
736
        $aMean = self::AVERAGE($aArgs);
737
        if ($aMean != Functions::DIV0()) {
738
            $aCount = 0;
739
            foreach ($aArgs as $k => $arg) {
740
                if ((is_bool($arg)) &&
741
                    ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) {
742
                    $arg = (int) $arg;
743
                }
744
                // Is it a numeric value?
745
                if ((is_numeric($arg)) && (!is_string($arg))) {
746
                    if (is_null($returnValue)) {
747
                        $returnValue = abs($arg - $aMean);
748
                    } else {
749
                        $returnValue += abs($arg - $aMean);
750
                    }
751
                    ++$aCount;
752
                }
753
            }
754
755
            // Return
756
            if ($aCount == 0) {
757
                return Functions::DIV0();
758
            }
759
760
            return $returnValue / $aCount;
761
        }
762
763
        return Functions::NAN();
764
    }
765
766
    /**
767
     * AVERAGE.
@@ 1502-1538 (lines=37) @@
1499
     *
1500
     * @return    float
1501
     */
1502
    public static function DEVSQ()
1503
    {
1504
        $aArgs = Functions::flattenArrayIndexed(func_get_args());
1505
1506
        // Return value
1507
        $returnValue = null;
1508
1509
        $aMean = self::AVERAGE($aArgs);
1510
        if ($aMean != Functions::DIV0()) {
1511
            $aCount = -1;
1512
            foreach ($aArgs as $k => $arg) {
1513
                // Is it a numeric value?
1514
                if ((is_bool($arg)) &&
1515
                    ((!Functions::isCellValue($k)) ||
1516
                    (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) {
1517
                    $arg = (int) $arg;
1518
                }
1519
                if ((is_numeric($arg)) && (!is_string($arg))) {
1520
                    if (is_null($returnValue)) {
1521
                        $returnValue = pow(($arg - $aMean), 2);
1522
                    } else {
1523
                        $returnValue += pow(($arg - $aMean), 2);
1524
                    }
1525
                    ++$aCount;
1526
                }
1527
            }
1528
1529
            // Return
1530
            if (is_null($returnValue)) {
1531
                return Functions::NAN();
1532
            }
1533
1534
            return $returnValue;
1535
        }
1536
1537
        return self::NA();
1538
    }
1539
1540
    /**
1541
     * EXPONDIST.