Identity and Access Control - simplified, but not anemic.
use texdc\veritas\identity\CryptoServiceInterface;
use texdc\veritas\identity\Password;
class User
{
/**
* @var Password
*/
private $password;
// ...
public function changePassword(string $aPassword, CryptoServiceInterface $aCryptoService)
{
$this->setPassword(new Password($aCryptoService->encrypt($aPassword)));
$this->eventService->publish(new PasswordChangedEvent($this->userId));
}
protected function setPassword(Password $aPassword)
{
if ($this->password == $aPassword) {
throw new IdenticalPasswordException;
}
$this->password = $aPassword;
}
// ...
}