public function encode($value)
{
if (!is_numeric($value)) {
throw new InvalidArgumentException('Argument should be an integer');
}
switch (static::$mode) {
case self::MODE_GMP:
return gmp_intval(gmp_mul($value, $this->prime)) & static::MAX_INT ^ $this->xor;
default:
return (int) $value * $this->prime & static::MAX_INT ^ $this->xor;
}
}