But when you create a new UserIdentity($username, $password) instance, it doesn’t know anything about user id. So both commands above will return the same value ($username).
If you want to store user id, you should override the getId() method to return what you need. But it’s optional