There's no problem getting the name of the desired properties, as long as you correctly return what the interface
implemented requires.
An interface in PHP "forces" the class to have the methods that are determined on it.
So, what you use the
Symfony\Component\Security\Core\User\UserInterface
interface, you have to return
$senha
to method
getPassword
and
usuario
to
getUsername
method.
There are also other methods that need to be implemented from this interface
Recommended readings:
Example taken from Symfony
page:
namespace AppBundle\Security\User;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;
class WebserviceUser implements UserInterface, EquatableInterface
{
private $usuario;
private $senha;
private $salt;
private $roles;
public function __construct($usuario, $senha, $salt, array $roles)
{
$this->usuario = $usuario;
$this->senha = $senha;
$this->salt = $salt;
$this->roles = $roles;
}
public function getRoles()
{
return $this->roles;
}
public function getPassword()
{
return $this->senha;
}
public function getSalt()
{
return $this->salt;
}
public function getUsername()
{
return $this->usuario;
}
public function eraseCredentials()
{
}
public function isEqualTo(UserInterface $user)
{
if (!$user instanceof WebserviceUser) {
return false;
}
if ($this->senha !== $user->getPassword()) {
return false;
}
if ($this->salt !== $user->getSalt()) {
return false;
}
if ($this->usuario !== $user->getUsername()) {
return false;
}
return true;
}
}