Code Duplication    Length = 17-17 lines in 5 locations

src/PhpSpreadsheet/Calculation/Statistical.php 5 locations

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