class User (View source)

The User type is a custom data type that stores all data that is related to a user.

Properties

$email The user's email.
$name The username.
private $passwordHash The encrypted password.

Methods

__construct(string $name, string $password, string|null $email = null)

The constructor.

array
__serialize()

Serialize object.

__unserialize(array $properties)

Unserialize object.

string
getPasswordHash()

Get a hashed version of a user password.

setPasswordHash(string $password)

Store a hashed version of a given clear text password.

bool
verifyPassword(string $password)

Verify if a password matches its saved hashed version.

string
hash(string $password)

Create hash from password to store in accounts.txt.

Details

__construct(string $name, string $password, string|null $email = null)

The constructor.

Parameters

string $name
string $password
string|null $email

array __serialize()

Serialize object.

Return Value

array the associative array of properties

__unserialize(array $properties)

Unserialize object.

Parameters

array $properties

string getPasswordHash()

Get a hashed version of a user password.

Return Value

string the hashed password

setPasswordHash(string $password)

Store a hashed version of a given clear text password.

Parameters

string $password

bool verifyPassword(string $password)

Verify if a password matches its saved hashed version.

Parameters

string $password

Return Value

bool true if the password is verified

private string hash(string $password)

Create hash from password to store in accounts.txt.

Parameters

string $password

Return Value

string Hashed/salted password