2024-05-14 02:06:01 +00:00
|
|
|
<?php
|
|
|
|
|
2024-05-24 01:24:57 +00:00
|
|
|
namespace Slovocast\Domain\Entity;
|
|
|
|
|
|
|
|
use Slovocast\Domain\Entity;
|
2024-05-14 02:06:01 +00:00
|
|
|
|
|
|
|
class User
|
|
|
|
{
|
2024-05-24 01:24:57 +00:00
|
|
|
use Entity;
|
|
|
|
|
2024-05-14 02:06:01 +00:00
|
|
|
public function __construct(
|
|
|
|
private string $email,
|
|
|
|
private string $password,
|
|
|
|
private string $name
|
2024-05-24 01:24:57 +00:00
|
|
|
) { }
|
2024-05-14 02:06:01 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-05-14 02:06:01 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-05-14 02:06:01 +00:00
|
|
|
public function getName(): string
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
2024-05-30 01:56:42 +00:00
|
|
|
public function setName(string $name): User
|
2024-05-14 02:06:01 +00:00
|
|
|
{
|
2024-05-30 01:56:42 +00:00
|
|
|
$this->name = $name;
|
|
|
|
return $this;
|
2024-05-14 02:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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']);
|
2024-05-24 01:24:57 +00:00
|
|
|
|
2024-06-03 01:26:10 +00:00
|
|
|
if (array_key_exists('id', $props)) {
|
2024-05-24 01:24:57 +00:00
|
|
|
$user->setId($props['id']);
|
|
|
|
}
|
|
|
|
|
2024-06-03 01:26:10 +00:00
|
|
|
if (array_key_exists('createdAt', $props)) {
|
2024-05-30 01:56:42 +00:00
|
|
|
$user->setCreatedAt($props['createdAt']);
|
|
|
|
}
|
|
|
|
|
2024-06-03 01:26:10 +00:00
|
|
|
if (array_key_exists('updatedAt', $props)) {
|
2024-05-30 01:56:42 +00:00
|
|
|
$user->setUpdatedAt($props['updatedAt']);
|
|
|
|
}
|
2024-05-24 01:24:57 +00:00
|
|
|
|
|
|
|
return $user;
|
2024-05-14 02:06:01 +00:00
|
|
|
}
|
|
|
|
}
|