public function getUserByName($username)
{
return $this->getUsers()->then(function (array $users) use($username) {
foreach ($users as $user) {
if ($user->getUsername() === $username) {
return $user;
}
}
throw new UserNotFoundException("The user \"{$username}\" does not exist.");
});
}