Code Duplication    Length = 25-26 lines in 2 locations

src/PhpSpreadsheet/Calculation/Engineering.php 2 locations

@@ 1376-1400 (lines=25) @@
1373
     *                                If places is zero or negative, DEC2HEX returns the #NUM! error value.
1374
     * @return    string
1375
     */
1376
    public static function DECTOHEX($x, $places = null)
1377
    {
1378
        $x = Functions::flattenSingleValue($x);
1379
        $places = Functions::flattenSingleValue($places);
1380
1381
        if (is_bool($x)) {
1382
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
1383
                $x = (int)$x;
1384
            } else {
1385
                return Functions::VALUE();
1386
            }
1387
        }
1388
        $x = (string)$x;
1389
        if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) {
1390
            return Functions::VALUE();
1391
        }
1392
        $x = (string)floor($x);
1393
        $r = strtoupper(dechex($x));
1394
        if (strlen($r) == 8) {
1395
            //    Two's Complement
1396
            $r = 'FF' . $r;
1397
        }
1398
1399
        return self::nbrConversionFormat($r, $places);
1400
    }
1401
1402
1403
    /**
@@ 1431-1456 (lines=26) @@
1428
     *                                If places is zero or negative, DEC2OCT returns the #NUM! error value.
1429
     * @return    string
1430
     */
1431
    public static function DECTOOCT($x, $places = null)
1432
    {
1433
        $xorig = $x;
1434
        $x = Functions::flattenSingleValue($x);
1435
        $places = Functions::flattenSingleValue($places);
1436
1437
        if (is_bool($x)) {
1438
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
1439
                $x = (int)$x;
1440
            } else {
1441
                return Functions::VALUE();
1442
            }
1443
        }
1444
        $x = (string)$x;
1445
        if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) {
1446
            return Functions::VALUE();
1447
        }
1448
        $x = (string)floor($x);
1449
        $r = decoct($x);
1450
        if (strlen($r) == 11) {
1451
            //    Two's Complement
1452
            $r = substr($r, -10);
1453
        }
1454
1455
        return self::nbrConversionFormat($r, $places);
1456
    }
1457
1458
1459
    /**