= 0; --$i) { $index = (int)floor($input / (62 ** $i)); $output .= substr(self::CHARS, $index, 1); $input -= $index * (62 ** $i); } return $output; } /** * Decodes a Base62 string back to an integer. * * @param Stream|string $input Input Base62 string. * @return int Integer. */ public function deserialise(Stream|string $input): mixed { $input = (string)$input; $output = 0; $length = strlen($input) - 1; for($i = 0; $i <= $length; ++$i) $output += strpos(self::CHARS, $input[$i]) * (62 ** ($length - $i)); return $output; } }