slovocast/app/src/Domain/Entity/User.php

73 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace Slovocast\Domain\Entity;
use Slovocast\Domain\Entity;
class User
{
use Entity;
public function __construct(
private string $email,
private string $password,
private string $name
) { }
public function getEmail(): string
{
return $this->email;
}
2024-05-30 01:56:42 +00:00
public function setEmail(string $email): User
{
$this->email = $email;
return $this;
}
public function getPassword(): string
{
return $this->password;
}
2024-05-30 01:56:42 +00:00
public function setPassword(string $password): User
{
$this->password = $password;
return $this;
}
public function getName(): string
{
return $this->name;
}
2024-05-30 01:56:42 +00:00
public function setName(string $name): User
{
2024-05-30 01:56:42 +00:00
$this->name = $name;
return $this;
}
/**
* @param string[] $props Properties of the User model
* @return User
*/
public static function fromArray(array $props): User
{
2024-05-30 01:56:42 +00:00
$user = new self($props['email'], $props['password'], $props['name']);
if ($props['id']) {
$user->setId($props['id']);
}
2024-05-30 01:56:42 +00:00
if ($props['createdAt']) {
$user->setCreatedAt($props['createdAt']);
}
if ($props['updatedAt']) {
$user->setUpdatedAt($props['updatedAt']);
}
return $user;
}
}