Code Duplication    Length = 29-30 lines in 2 locations

src/PhpSpreadsheet/Calculation/Engineering.php 2 locations

@@ 1249-1277 (lines=29) @@
1246
     *
1247
     * @return string
1248
     */
1249
    public static function BINTOOCT($x, $places = null)
1250
    {
1251
        $x = Functions::flattenSingleValue($x);
1252
        $places = Functions::flattenSingleValue($places);
1253
1254
        if (is_bool($x)) {
1255
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
1256
                $x = (int) $x;
1257
            } else {
1258
                return Functions::VALUE();
1259
            }
1260
        }
1261
        if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1262
            $x = floor($x);
1263
        }
1264
        $x = (string) $x;
1265
        if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
1266
            return Functions::NAN();
1267
        }
1268
        if (strlen($x) > 10) {
1269
            return Functions::NAN();
1270
        } elseif (strlen($x) == 10) {
1271
            //    Two's Complement
1272
            return str_repeat('7', 7) . substr(strtoupper(decoct(bindec(substr($x, -9)))), -3);
1273
        }
1274
        $octVal = (string) decoct(bindec($x));
1275
1276
        return self::nbrConversionFormat($octVal, $places);
1277
    }
1278
1279
    /**
1280
     * DECTOBIN.
@@ 1193-1222 (lines=30) @@
1190
     *
1191
     * @return string
1192
     */
1193
    public static function BINTOHEX($x, $places = null)
1194
    {
1195
        $x = Functions::flattenSingleValue($x);
1196
        $places = Functions::flattenSingleValue($places);
1197
1198
        // Argument X
1199
        if (is_bool($x)) {
1200
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
1201
                $x = (int) $x;
1202
            } else {
1203
                return Functions::VALUE();
1204
            }
1205
        }
1206
        if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1207
            $x = floor($x);
1208
        }
1209
        $x = (string) $x;
1210
        if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
1211
            return Functions::NAN();
1212
        }
1213
        if (strlen($x) > 10) {
1214
            return Functions::NAN();
1215
        } elseif (strlen($x) == 10) {
1216
            //    Two's Complement
1217
            return str_repeat('F', 8) . substr(strtoupper(dechex(bindec(substr($x, -9)))), -2);
1218
        }
1219
        $hexVal = (string) strtoupper(dechex(bindec($x)));
1220
1221
        return self::nbrConversionFormat($hexVal, $places);
1222
    }
1223
1224
    /**
1225
     * BINTOOCT.