public static function ParagonIE_Sodium_Compat::compare in Automatic Updates 8
Same name and namespace in other branches
- 7 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::compare()
Compare two strings, in constant-time. Compared to memcmp(), compare() is more useful for sorting.
@psalm-suppress MixedArgument
Parameters
string $left The left operand; must be a string:
string $right The right operand; must be a string:
Return value
int If < 0 if the left operand is less than the right If = 0 if both strings are equal If > 0 if the right operand is less than the left
Throws
SodiumException
TypeError
2 calls to ParagonIE_Sodium_Compat::compare()
- php72compat.php in vendor/
paragonie/ sodium_compat/ lib/ php72compat.php - sodium_compat.php in vendor/
paragonie/ sodium_compat/ lib/ sodium_compat.php
File
- vendor/
paragonie/ sodium_compat/ src/ Compat.php, line 279
Class
Code
public static function compare($left, $right) {
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2);
if (self::useNewSodiumAPI()) {
return (int) sodium_compare($left, $right);
}
if (self::use_fallback('compare')) {
return (int) call_user_func('\\Sodium\\compare', $left, $right);
}
return ParagonIE_Sodium_Core_Util::compare($left, $right);
}