for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SumoCoders\FrameworkMultiUserBundle\Security;
use SumoCoders\FrameworkMultiUserBundle\Exception\InvalidPasswordResetTokenException;
use SumoCoders\FrameworkMultiUserBundle\User\UserInterface;
class PasswordResetToken
{
/**
* @var string
*/
private $token;
* PasswordResetToken constructor.
*
* @param string $token
public function __construct($token)
$this->token = $token;
}
* @return string
public function getToken()
return $this->token;
* @param UserInterface $user
* @param $token
* @throws InvalidPasswordResetTokenException
* @return bool
public static function validateToken(UserInterface $user, PasswordResetToken $token)
if ($user->getPasswordResetToken()->equals($token)) {
getPasswordResetToken()
SumoCoders\FrameworkMult...ndle\User\UserInterface
getPassword()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
return true;
throw new InvalidPasswordResetTokenException('The given token is not valid.');
* Generates a PasswordToken
* @return PasswordResetToken
public static function generate()
$token = time() . base64_encode(random_bytes(10));
return new self($token);
* Check if a token is equal to a different token.
* @param PasswordResetToken $token
public function equals(PasswordResetToken $token)
return $token->token === $this->token;
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.