Code Duplication    Length = 8-8 lines in 2 locations

src/library/sodium_compat/src/Compat.php 2 locations

@@ 984-991 (lines=8) @@
981
        ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 3);
982
983
        /* Input validation: */
984
        if (!empty($key)) {
985
            if (ParagonIE_Sodium_Core_Util::strlen($key) < self::CRYPTO_GENERICHASH_KEYBYTES_MIN) {
986
                throw new Error('Unsupported key size. Must be at least CRYPTO_GENERICHASH_KEYBYTES_MIN bytes long.');
987
            }
988
            if (ParagonIE_Sodium_Core_Util::strlen($key) > self::CRYPTO_GENERICHASH_KEYBYTES_MAX) {
989
                throw new Error('Unsupported key size. Must be at most CRYPTO_GENERICHASH_KEYBYTES_MAX bytes long.');
990
            }
991
        }
992
993
        if (self::isPhp72OrGreater()) {
994
            return sodium_crypto_generichash($message, $key, $length);
@@ 1060-1067 (lines=8) @@
1057
        ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 2);
1058
1059
        /* Input validation: */
1060
        if (!empty($key)) {
1061
            if (ParagonIE_Sodium_Core_Util::strlen($key) < self::CRYPTO_GENERICHASH_KEYBYTES_MIN) {
1062
                throw new Error('Unsupported key size. Must be at least CRYPTO_GENERICHASH_KEYBYTES_MIN bytes long.');
1063
            }
1064
            if (ParagonIE_Sodium_Core_Util::strlen($key) > self::CRYPTO_GENERICHASH_KEYBYTES_MAX) {
1065
                throw new Error('Unsupported key size. Must be at most CRYPTO_GENERICHASH_KEYBYTES_MAX bytes long.');
1066
            }
1067
        }
1068
1069
        if (self::isPhp72OrGreater()) {
1070
            return sodium_crypto_generichash_init($key, $length);