/**
  * @return \PHPSC\Conference\Domain\Entity\User
  */
 public function getLoggedUser()
 {
     if (!$this->isLogged() && $this->session->has('loggedUser')) {
         $this->loggedUser = $this->userManager->getById($this->session->get('loggedUser'));
     }
     return $this->loggedUser;
 }
 /**
  * @param int $id
  * @param string $name
  * @param string $email
  * @param string $bio
  * @return string
  */
 public function update($id, $name, $email, $bio)
 {
     $user = $this->authService->getLoggedUser();
     try {
         if ($user->getId() != $id) {
             throw new InvalidArgumentException('Você não pode alterar os dados de outro usuário');
         }
         $user = $this->userManager->update($id, $name, $email, !empty($bio) ? $bio : null);
         return json_encode(array('data' => array('id' => $user->getId(), 'username' => $user->getDefaultProfile()->getUsername())));
     } catch (InvalidArgumentException $error) {
         return json_encode(array('error' => $error->getMessage()));
     } catch (PDOException $error) {
         return json_encode(array('error' => 'Não foi possível salvar os dados na camada de persistência'));
     } catch (Exception $error) {
         return json_encode(array('error' => 'Erro interno no processamento da requisição'));
     }
 }