Code Duplication    Length = 18-18 lines in 5 locations

src/PhpSpreadsheet/Calculation/Statistical.php 5 locations

@@ 1346-1363 (lines=18) @@
1343
     *
1344
     * @return    float
1345
     */
1346
    public static function COVAR($yValues, $xValues)
1347
    {
1348
        if (!self::checkTrendArrays($yValues, $xValues)) {
1349
            return Functions::VALUE();
1350
        }
1351
        $yValueCount = count($yValues);
1352
        $xValueCount = count($xValues);
1353
1354
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
1355
            return Functions::NA();
1356
        } elseif ($yValueCount == 1) {
1357
            return Functions::DIV0();
1358
        }
1359
1360
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
1361
1362
        return $bestFitLinear->getCovariance();
1363
    }
1364
1365
    /**
1366
     * CRITBINOM.
@@ 1947-1964 (lines=18) @@
1944
     *
1945
     * @return    float
1946
     */
1947
    public static function INTERCEPT($yValues, $xValues)
1948
    {
1949
        if (!self::checkTrendArrays($yValues, $xValues)) {
1950
            return Functions::VALUE();
1951
        }
1952
        $yValueCount = count($yValues);
1953
        $xValueCount = count($xValues);
1954
1955
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
1956
            return Functions::NA();
1957
        } elseif ($yValueCount == 1) {
1958
            return Functions::DIV0();
1959
        }
1960
1961
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
1962
1963
        return $bestFitLinear->getIntersect();
1964
    }
1965
1966
    /**
1967
     * KURT.
@@ 2998-3015 (lines=18) @@
2995
     *
2996
     * @return    float
2997
     */
2998
    public static function RSQ($yValues, $xValues)
2999
    {
3000
        if (!self::checkTrendArrays($yValues, $xValues)) {
3001
            return Functions::VALUE();
3002
        }
3003
        $yValueCount = count($yValues);
3004
        $xValueCount = count($xValues);
3005
3006
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
3007
            return Functions::NA();
3008
        } elseif ($yValueCount == 1) {
3009
            return Functions::DIV0();
3010
        }
3011
3012
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
3013
3014
        return $bestFitLinear->getGoodnessOfFit();
3015
    }
3016
3017
    /**
3018
     * SKEW.
@@ 3068-3085 (lines=18) @@
3065
     *
3066
     * @return    float
3067
     */
3068
    public static function SLOPE($yValues, $xValues)
3069
    {
3070
        if (!self::checkTrendArrays($yValues, $xValues)) {
3071
            return Functions::VALUE();
3072
        }
3073
        $yValueCount = count($yValues);
3074
        $xValueCount = count($xValues);
3075
3076
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
3077
            return Functions::NA();
3078
        } elseif ($yValueCount == 1) {
3079
            return Functions::DIV0();
3080
        }
3081
3082
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
3083
3084
        return $bestFitLinear->getSlope();
3085
    }
3086
3087
    /**
3088
     * SMALL.
@@ 3372-3389 (lines=18) @@
3369
     *
3370
     * @return    float
3371
     */
3372
    public static function STEYX($yValues, $xValues)
3373
    {
3374
        if (!self::checkTrendArrays($yValues, $xValues)) {
3375
            return Functions::VALUE();
3376
        }
3377
        $yValueCount = count($yValues);
3378
        $xValueCount = count($xValues);
3379
3380
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
3381
            return Functions::NA();
3382
        } elseif ($yValueCount == 1) {
3383
            return Functions::DIV0();
3384
        }
3385
3386
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
3387
3388
        return $bestFitLinear->getStdevOfResiduals();
3389
    }
3390
3391
    /**
3392
     * TDIST.