Skip to content

Instantly share code, notes, and snippets.

@smottt
Created June 22, 2012 08:32
Show Gist options
  • Select an option

  • Save smottt/2971338 to your computer and use it in GitHub Desktop.

Select an option

Save smottt/2971338 to your computer and use it in GitHub Desktop.
UserInterface equals method
<?php
class User implements UserInterface
{
// ...
/**
* Compares this user to another to determine if they are the same.
*
* @param UserInterface $user
* @return boolean True if equal, false otherwise.
*/
public function equals(UserInterface $user)
{
return
md5($user->getUsername()) == md5($this->getUsername()) &&
md5(serialize($user->getRoles())) == md5(serialize($this->getRoles()));
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment