Code Duplication    Length = 27-27 lines in 2 locations

src/PhpSpreadsheet/Calculation/Financial.php 2 locations

@@ 1067-1093 (lines=27) @@
1064
     *
1065
     * @return float
1066
     */
1067
    public static function DISC($settlement, $maturity, $price, $redemption, $basis = 0)
1068
    {
1069
        $settlement = Functions::flattenSingleValue($settlement);
1070
        $maturity = Functions::flattenSingleValue($maturity);
1071
        $price = Functions::flattenSingleValue($price);
1072
        $redemption = Functions::flattenSingleValue($redemption);
1073
        $basis = Functions::flattenSingleValue($basis);
1074
1075
        //    Validate
1076
        if ((is_numeric($price)) && (is_numeric($redemption)) && (is_numeric($basis))) {
1077
            $price = (float) $price;
1078
            $redemption = (float) $redemption;
1079
            $basis = (int) $basis;
1080
            if (($price <= 0) || ($redemption <= 0)) {
1081
                return Functions::NAN();
1082
            }
1083
            $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
1084
            if (!is_numeric($daysBetweenSettlementAndMaturity)) {
1085
                //    return date error
1086
                return $daysBetweenSettlementAndMaturity;
1087
            }
1088
1089
            return (1 - $price / $redemption) / $daysBetweenSettlementAndMaturity;
1090
        }
1091
1092
        return Functions::VALUE();
1093
    }
1094
1095
    /**
1096
     * DOLLARDE.
@@ 1293-1319 (lines=27) @@
1290
     *
1291
     * @return float
1292
     */
1293
    public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis = 0)
1294
    {
1295
        $settlement = Functions::flattenSingleValue($settlement);
1296
        $maturity = Functions::flattenSingleValue($maturity);
1297
        $investment = Functions::flattenSingleValue($investment);
1298
        $redemption = Functions::flattenSingleValue($redemption);
1299
        $basis = Functions::flattenSingleValue($basis);
1300
1301
        //    Validate
1302
        if ((is_numeric($investment)) && (is_numeric($redemption)) && (is_numeric($basis))) {
1303
            $investment = (float) $investment;
1304
            $redemption = (float) $redemption;
1305
            $basis = (int) $basis;
1306
            if (($investment <= 0) || ($redemption <= 0)) {
1307
                return Functions::NAN();
1308
            }
1309
            $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis);
1310
            if (!is_numeric($daysBetweenSettlementAndMaturity)) {
1311
                //    return date error
1312
                return $daysBetweenSettlementAndMaturity;
1313
            }
1314
1315
            return (($redemption / $investment) - 1) / ($daysBetweenSettlementAndMaturity);
1316
        }
1317
1318
        return Functions::VALUE();
1319
    }
1320
1321
    /**
1322
     * IPMT.