/**
  * @param ChangeUsernameCommand $command
  *
  * @return User
  */
 protected function handleChangeUsername(ChangeUsernameCommand $command)
 {
     $userIdentifier = new UserIdentifier($command->userIdentifier());
     $newUsername = new Username($command->newUsername());
     $user = $this->userRepository->load($userIdentifier);
     $user->changeUsername($newUsername);
     return $user;
 }
 /**
  * @param ChangeUserPasswordCommand $command
  *
  * @return User
  */
 protected function handleChangeUserPassword(ChangeUserPasswordCommand $command)
 {
     $userIdentifier = new UserIdentifier($command->userIdentifier());
     $newPassword = new Password($command->newPassword());
     $hashedPassword = $this->passwordHashingService->hashPassword($newPassword);
     $user = $this->userRepository->load($userIdentifier);
     $user->changePassword($hashedPassword);
     return $user;
 }