Skip to content

Commit

Permalink
Change names to Equatable
Browse files Browse the repository at this point in the history
  • Loading branch information
canni committed Jan 10, 2012
1 parent 680b108 commit 56db4a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Expand Up @@ -15,7 +15,7 @@
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Security\Core\User\ComparableInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;

/**
* Base class for Token instances.
Expand Down Expand Up @@ -89,7 +89,7 @@ public function setUser($user)
if (!$user instanceof UserInterface) {
$changed = true;
} else {
$changed = !$this->compareUser($user);
$changed = !$this->isUserChanged($user);
}
} elseif ($user instanceof UserInterface) {
$changed = true;
Expand Down Expand Up @@ -223,14 +223,14 @@ public function __toString()
return sprintf('%s(user="%s", authenticated=%s, roles="%s")', $class, $this->getUsername(), json_encode($this->authenticated), implode(', ', $roles));
}

private function compareUser(UserInterface $user)
private function isUserChanged(UserInterface $user)
{
if (!($this->user instanceof UserInterface)) {
throw new \BadMethodCallException('Method "compareUser" should be called when current user class is instance of "UserInterface".');
}

if ($this->user instanceof ComparableInterface) {
return $this->user->compareTo($user);
if ($this->user instanceof EquatableInterface) {
return $this->user->isEqualTo($user);
}

if ($this->user->getPassword() !== $user->getPassword()) {
Expand Down
Expand Up @@ -12,12 +12,12 @@
namespace Symfony\Component\Security\Core\User;

/**
* ComparableInterface used to test if two objects are equal in security
* EquatableInterface used to test if two objects are equal in security
* and re-authentication context.
*
* @author Dariusz Górecki <darek.krk@gmail.com>
*/
interface ComparableInterface
interface EquatableInterface
{
/**
* The equality comparison should neither be done by referential equality
Expand All @@ -30,5 +30,5 @@ interface ComparableInterface
*
* @return Boolean
*/
function compareTo(UserInterface $user);
function isEqualTo(UserInterface $user);
}

0 comments on commit 56db4a1

Please sign in to comment.