Code Duplication    Length = 15-16 lines in 3 locations

src/PhpSpreadsheet/Calculation/Engineering.php 3 locations

@@ 1480-1494 (lines=15) @@
1477
     *
1478
     * @return string
1479
     */
1480
    public static function HEXTOBIN($x, $places = null)
1481
    {
1482
        $x = Functions::flattenSingleValue($x);
1483
        $places = Functions::flattenSingleValue($places);
1484
1485
        if (is_bool($x)) {
1486
            return Functions::VALUE();
1487
        }
1488
        $x = (string) $x;
1489
        if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
1490
            return Functions::NAN();
1491
        }
1492
1493
        return self::DECTOBIN(self::HEXTODEC($x), $places);
1494
    }
1495
1496
    /**
1497
     * HEXTODEC.
@@ 1636-1650 (lines=15) @@
1633
     *
1634
     * @return string
1635
     */
1636
    public static function OCTTOBIN($x, $places = null)
1637
    {
1638
        $x = Functions::flattenSingleValue($x);
1639
        $places = Functions::flattenSingleValue($places);
1640
1641
        if (is_bool($x)) {
1642
            return Functions::VALUE();
1643
        }
1644
        $x = (string) $x;
1645
        if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
1646
            return Functions::NAN();
1647
        }
1648
1649
        return self::DECTOBIN(self::OCTTODEC($x), $places);
1650
    }
1651
1652
    /**
1653
     * OCTTODEC.
@@ 1728-1743 (lines=16) @@
1725
     *
1726
     * @return string
1727
     */
1728
    public static function OCTTOHEX($x, $places = null)
1729
    {
1730
        $x = Functions::flattenSingleValue($x);
1731
        $places = Functions::flattenSingleValue($places);
1732
1733
        if (is_bool($x)) {
1734
            return Functions::VALUE();
1735
        }
1736
        $x = (string) $x;
1737
        if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
1738
            return Functions::NAN();
1739
        }
1740
        $hexVal = strtoupper(dechex(self::OCTTODEC($x)));
1741
1742
        return self::nbrConversionFormat($hexVal, $places);
1743
    }
1744
1745
    /**
1746
     * COMPLEX.