<?php
declare(strict_types=1);
namespace App\Domains\User\Domain\Entity;
use App\Domains\User\Infrastructure\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private string $email;
#[ORM\Column]
private array $roles;
#[ORM\Column]
private string $password;
#[ORM\Column(length: 255)]
private string $firstName;
#[ORM\Column(length: 255)]
private string $lastName;
#[ORM\Column(length: 50, nullable: true)]
private ?string $status;
#[ORM\Column(length: 255, nullable: true)]
private ?string $googleId = null;
public function __construct(
string $email,
string $password,
string $firstName,
string $lastName,
array $roles = ['ROLE_USER'],
?string $status = null
) {
$this->email = $email;
$this->password = $password;
$this->firstName = $firstName;
$this->lastName = $lastName;
$this->roles = $roles;
$this->status = $status;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): string
{
return $this->email;
}
public function getFirstName(): string
{
return $this->firstName;
}
public function getLastName(): string
{
return $this->lastName;
}
public function getStatus(): ?string
{
return $this->status;
}
public function getGoogleId(): ?string
{
return $this->googleId;
}
public function setFirstName(string $firstName): void
{
$this->firstName = $firstName;
}
public function setLastName(string $lastName): void
{
$this->lastName = $lastName;
}
public function setGoogleId(string $googleId): void
{
$this->googleId = $googleId;
}
public function getUserIdentifier(): string
{
return $this->email;
}
public function getRoles(): array
{
$roles = $this->roles;
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function getPassword(): string
{
return $this->password;
}
public function eraseCredentials(): void
{
// Clear any sensitive temporary data here, if needed
}
}