Code Duplication    Length = 18-18 lines in 5 locations

src/PhpSpreadsheet/Calculation/Statistical.php 5 locations

@@ 1295-1312 (lines=18) @@
1292
     * @param    array of mixed        Data Series X
1293
     * @return    float
1294
     */
1295
    public static function COVAR($yValues, $xValues)
1296
    {
1297
        if (!self::checkTrendArrays($yValues, $xValues)) {
1298
            return Functions::VALUE();
1299
        }
1300
        $yValueCount = count($yValues);
1301
        $xValueCount = count($xValues);
1302
1303
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
1304
            return Functions::NA();
1305
        } elseif ($yValueCount == 1) {
1306
            return Functions::DIV0();
1307
        }
1308
1309
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
1310
1311
        return $bestFitLinear->getCovariance();
1312
    }
1313
1314
    /**
1315
     * CRITBINOM
@@ 1870-1887 (lines=18) @@
1867
     * @param    array of mixed        Data Series X
1868
     * @return    float
1869
     */
1870
    public static function INTERCEPT($yValues, $xValues)
1871
    {
1872
        if (!self::checkTrendArrays($yValues, $xValues)) {
1873
            return Functions::VALUE();
1874
        }
1875
        $yValueCount = count($yValues);
1876
        $xValueCount = count($xValues);
1877
1878
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
1879
            return Functions::NA();
1880
        } elseif ($yValueCount == 1) {
1881
            return Functions::DIV0();
1882
        }
1883
1884
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
1885
1886
        return $bestFitLinear->getIntersect();
1887
    }
1888
1889
    /**
1890
     * KURT
@@ 2865-2882 (lines=18) @@
2862
     * @param    array of mixed        Data Series X
2863
     * @return    float
2864
     */
2865
    public static function RSQ($yValues, $xValues)
2866
    {
2867
        if (!self::checkTrendArrays($yValues, $xValues)) {
2868
            return Functions::VALUE();
2869
        }
2870
        $yValueCount = count($yValues);
2871
        $xValueCount = count($xValues);
2872
2873
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
2874
            return Functions::NA();
2875
        } elseif ($yValueCount == 1) {
2876
            return Functions::DIV0();
2877
        }
2878
2879
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
2880
2881
        return $bestFitLinear->getGoodnessOfFit();
2882
    }
2883
2884
    /**
2885
     * SKEW
@@ 2931-2948 (lines=18) @@
2928
     * @param    array of mixed        Data Series X
2929
     * @return    float
2930
     */
2931
    public static function SLOPE($yValues, $xValues)
2932
    {
2933
        if (!self::checkTrendArrays($yValues, $xValues)) {
2934
            return Functions::VALUE();
2935
        }
2936
        $yValueCount = count($yValues);
2937
        $xValueCount = count($xValues);
2938
2939
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
2940
            return Functions::NA();
2941
        } elseif ($yValueCount == 1) {
2942
            return Functions::DIV0();
2943
        }
2944
2945
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
2946
2947
        return $bestFitLinear->getSlope();
2948
    }
2949
2950
    /**
2951
     * SMALL
@@ 3221-3238 (lines=18) @@
3218
     * @param    array of mixed        Data Series X
3219
     * @return    float
3220
     */
3221
    public static function STEYX($yValues, $xValues)
3222
    {
3223
        if (!self::checkTrendArrays($yValues, $xValues)) {
3224
            return Functions::VALUE();
3225
        }
3226
        $yValueCount = count($yValues);
3227
        $xValueCount = count($xValues);
3228
3229
        if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
3230
            return Functions::NA();
3231
        } elseif ($yValueCount == 1) {
3232
            return Functions::DIV0();
3233
        }
3234
3235
        $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues);
3236
3237
        return $bestFitLinear->getStdevOfResiduals();
3238
    }
3239
3240
    /**
3241
     * TDIST