for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Jasny\Auth\User;
use Jasny\Auth\ContextInterface as Context;
use Jasny\Auth\UserInterface;
/**
* A simple user class which can be used be used instead of creating a custom user class.
*/
final class BasicUser implements UserInterface
{
/** @var string|int */
public $id;
protected string $hashedPassword = '';
public $role;
* @inheritDoc
public function getAuthId(): string
return (string)$this->id;
}
public function verifyPassword(string $password): bool
return password_verify($password, $this->hashedPassword);
public function getAuthChecksum(): string
return hash('sha256', $this->id . $this->hashedPassword);
public function getAuthRole(?Context $context = null)
return $this->role;
public function requiresMfa(): bool
return false;
* Factory method; create object from data loaded from DB.
*
* @param array $data
* @return static
public static function fromData(array $data): self
$user = new self();
foreach ($data as $key => $value) {
$user->{$key} = $value;
return $user;