Code Duplication    Length = 25-26 lines in 2 locations

src/PhpSpreadsheet/Calculation/Engineering.php 2 locations

@@ 1365-1389 (lines=25) @@
1362
     *                                If places is zero or negative, DEC2HEX returns the #NUM! error value.
1363
     * @return    string
1364
     */
1365
    public static function DECTOHEX($x, $places = null)
1366
    {
1367
        $x = Functions::flattenSingleValue($x);
1368
        $places = Functions::flattenSingleValue($places);
1369
1370
        if (is_bool($x)) {
1371
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
1372
                $x = (int) $x;
1373
            } else {
1374
                return Functions::VALUE();
1375
            }
1376
        }
1377
        $x = (string) $x;
1378
        if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) {
1379
            return Functions::VALUE();
1380
        }
1381
        $x = (string) floor($x);
1382
        $r = strtoupper(dechex($x));
1383
        if (strlen($r) == 8) {
1384
            //    Two's Complement
1385
            $r = 'FF' . $r;
1386
        }
1387
1388
        return self::nbrConversionFormat($r, $places);
1389
    }
1390
1391
    /**
1392
     * DECTOOCT
@@ 1418-1443 (lines=26) @@
1415
     *                                If places is zero or negative, DEC2OCT returns the #NUM! error value.
1416
     * @return    string
1417
     */
1418
    public static function DECTOOCT($x, $places = null)
1419
    {
1420
        $xorig = $x;
1421
        $x = Functions::flattenSingleValue($x);
1422
        $places = Functions::flattenSingleValue($places);
1423
1424
        if (is_bool($x)) {
1425
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
1426
                $x = (int) $x;
1427
            } else {
1428
                return Functions::VALUE();
1429
            }
1430
        }
1431
        $x = (string) $x;
1432
        if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) {
1433
            return Functions::VALUE();
1434
        }
1435
        $x = (string) floor($x);
1436
        $r = decoct($x);
1437
        if (strlen($r) == 11) {
1438
            //    Two's Complement
1439
            $r = substr($r, -10);
1440
        }
1441
1442
        return self::nbrConversionFormat($r, $places);
1443
    }
1444
1445
    /**
1446
     * HEXTOBIN