<?phpnamespace App\Ship\Entities;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping\MappedSuperclass;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;use App\Ship\Utils\FormattingUtil;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Security\Core\User\UserInterface;#[MappedSuperclass] // https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/inheritance-mapping.html#association-overrideclass UserEntity implements UserInterface{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: Types::INTEGER)] #[Groups(['read'])] private int $id; #[ORM\Column(type: Types::STRING, length: 255, nullable: true, unique: true)] #[Groups(['read'])] private ?string $externalCode = null; #[ORM\Column(type: Types::STRING, length: 150, nullable: false, unique: true)] #[Groups(['read'])] private string $phone; #[ORM\Column(type: Types::JSON)] #[Groups(['read'])] protected array $roles = []; #[Gedmo\Timestampable(on: 'create')] #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] protected $createdAt; #[Gedmo\Timestampable(on: 'update')] #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] protected $updatedAt; public function getId(): ?int { return $this->id; } public function getExternalCode(): ?string { return $this->externalCode; } public function setExternalCode($code) { $this->externalCode = $code; return $this; } public function setPhone($value): self { if (filter_var($value, FILTER_VALIDATE_EMAIL)) $this->phone = $value; else { $this->phone = (!empty($value)) ? FormattingUtil::phoneNumber($value) : $value; } return $this; } public function getPhone(): ?string { return $this->phone; } public function eraseCredentials() { // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } public function getSalt() { // not needed for apps that do not check user passwords } public function getRoles(): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; return \array_unique($roles); } public function setRoles(array $roles): void { $this->roles = $roles; } public function getUserIdentifier(): string { return $this->phone; }}