26 lines
673 B
PHP
26 lines
673 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domovoy\Models;
|
|
|
|
class User
|
|
{
|
|
public ?string $id = null;
|
|
public string $username = '';
|
|
public string $passwordHash = '';
|
|
public ?\DateTimeImmutable $createdAt = null;
|
|
public ?\DateTimeImmutable $updatedAt = null;
|
|
|
|
public static function fromArray(array $data): self
|
|
{
|
|
$user = new self();
|
|
$user->id = $data['id'];
|
|
$user->username = $data['username'];
|
|
$user->passwordHash = $data['password_hash'];
|
|
$user->createdAt = new \DateTimeImmutable($data['created_at']);
|
|
$user->updatedAt = new \DateTimeImmutable($data['updated_at']);
|
|
return $user;
|
|
}
|
|
}
|