src/Security/Entity/User.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Security\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use JetBrains\PhpStorm\Pure;
  6. use Serializable;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Uid\Uuid;
  10. /**
  11.  * @ORM\Table(name="app_security_user")
  12.  * @ORM\Entity(repositoryClass="App\Security\Repository\UserRepository")
  13.  */
  14. class User implements UserInterfaceSerializablePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @ORM\Column(type="integer")
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     protected int $id;
  22.     /**
  23.      * @ORM\Column(type="uuid", nullable=true)
  24.      */
  25.     protected string $uuid;
  26.     /**
  27.      * @ORM\Column(type="string", length=128, unique=true)
  28.      */
  29.     protected string $username;
  30.     /**
  31.      * @ORM\Column(type="string", length=64)
  32.      */
  33.     protected string $password;
  34.     /**
  35.      * @ORM\Column(type="string", length=254, unique=true, nullable=true)
  36.      */
  37.     protected ?string $email;
  38.     /**
  39.      * @var bool|null
  40.      * @ORM\Column(type="boolean", nullable=true)
  41.      */
  42.     protected ?bool $receiveMonitorResultEmail;
  43.     /**
  44.      * @var bool|null
  45.      * @ORM\Column(type="boolean", nullable=true)
  46.      */
  47.     protected ?bool $sendOnlyErrors;
  48.     /**
  49.      * @var string|null
  50.      * @ORM\Column(type="string", nullable=true)
  51.      */
  52.     protected ?string $environmentNotificationLevel;
  53.     /**
  54.      * @var Token[]
  55.      * @ORM\OneToMany(targetEntity="App\Security\Entity\Token", mappedBy="user", fetch="EXTRA_LAZY")
  56.      */
  57.     protected array|Collection $tokens;
  58.     /**
  59.      * @ORM\Column(name="is_active", type="boolean")
  60.      */
  61.     protected bool $isActive;
  62.     /**
  63.      * @var string|null
  64.      * @ORM\Column(nullable=true)
  65.      */
  66.     protected ?string $name;
  67.     /**
  68.      * @var string|null
  69.      * @ORM\Column(nullable=true)
  70.      */
  71.     protected ?string $surname;
  72.     public function __construct()
  73.     {
  74.         $this->uuid Uuid::v4();
  75.         $this->isActive true;
  76.         $this->name null;
  77.         $this->surname null;
  78.     }
  79.     /**
  80.      * @return int
  81.      */
  82.     public function getId(): int
  83.     {
  84.         return $this->id;
  85.     }
  86.     /**
  87.      * @return Collection|array
  88.      */
  89.     public function getTokens(): Collection|array
  90.     {
  91.         return $this->tokens;
  92.     }
  93.     /**
  94.      * @param Token[] $tokens
  95.      * @return User
  96.      */
  97.     public function setTokens(Collection|array $tokens): User
  98.     {
  99.         $this->tokens $tokens;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return string|null
  104.      */
  105.     public function getName(): ?string
  106.     {
  107.         return $this->name;
  108.     }
  109.     /**
  110.      * @param string $name
  111.      * @return User
  112.      */
  113.     public function setName(string $name): User
  114.     {
  115.         $this->name $name;
  116.         return $this;
  117.     }
  118.     /**
  119.      * @return string|null
  120.      */
  121.     public function getSurname(): ?string
  122.     {
  123.         return $this->surname;
  124.     }
  125.     /**
  126.      * @param string $surname
  127.      * @return User
  128.      */
  129.     public function setSurname(string $surname): User
  130.     {
  131.         $this->surname $surname;
  132.         return $this;
  133.     }
  134.     public function getUsername(): string
  135.     {
  136.         return $this->username;
  137.     }
  138.     /**
  139.      * @param string $username
  140.      * @return User
  141.      */
  142.     public function setUsername(string $username): User
  143.     {
  144.         $this->username $username;
  145.         return $this;
  146.     }
  147.     /**
  148.      * @return string
  149.      */
  150.     public function getUuid(): string
  151.     {
  152.         return $this->uuid;
  153.     }
  154.     /**
  155.      * @param string $uuid
  156.      * @return User
  157.      */
  158.     public function setUuid(string $uuid): User
  159.     {
  160.         $this->uuid $uuid;
  161.         return $this;
  162.     }
  163.     /**
  164.      * @return string|null
  165.      */
  166.     public function getEmail(): ?string
  167.     {
  168.         return $this->email;
  169.     }
  170.     /**
  171.      * @param string $email
  172.      * @return User
  173.      */
  174.     public function setEmail(string $email): User
  175.     {
  176.         $this->email $email;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return string|null
  181.      */
  182.     public function getPassword(): ?string
  183.     {
  184.         return $this->password;
  185.     }
  186.     /**
  187.      * @param string $password
  188.      * @return User
  189.      */
  190.     public function setRawPassword(string $password): User
  191.     {
  192.         $this->password $password;
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return string[]
  197.      */
  198.     public function getRoles(): array
  199.     {
  200.         return array('ROLE_USER');
  201.     }
  202.     public function eraseCredentials()
  203.     {
  204.     }
  205.     /** @see \Serializable::serialize() */
  206.     public function serialize(): ?string
  207.     {
  208.         return serialize(array(
  209.             $this->id,
  210.             $this->username,
  211.             $this->password,
  212.             // see section on salt below
  213.             // $this->salt,
  214.         ));
  215.     }
  216.     /** @see \Serializable::unserialize() */
  217.     public function unserialize($data): void
  218.     {
  219.         list (
  220.             $this->id,
  221.             $this->username,
  222.             $this->password,
  223.             // see section on salt below
  224.             // $this->salt
  225.             ) = unserialize($data, array('allowed_classes' => false));
  226.     }
  227.     public function getPhoneNumber(): ?string
  228.     {
  229.         // TODO: Implement getPhoneNumber() method.
  230.         return null;
  231.     }
  232.     public function getUser(): ?User
  233.     {
  234.         return $this;
  235.     }
  236.     #[Pure] public function getUserIdentifier(): string
  237.     {
  238.         return $this->getUsername();
  239.     }
  240.     /**
  241.      * @return bool|null
  242.      */
  243.     public function getReceiveMonitorResultEmail(): ?bool
  244.     {
  245.         return $this->receiveMonitorResultEmail;
  246.     }
  247.     /**
  248.      * @param bool|null $receiveMonitorResultEmail
  249.      */
  250.     public function setReceiveMonitorResultEmail(?bool $receiveMonitorResultEmail): void
  251.     {
  252.         $this->receiveMonitorResultEmail $receiveMonitorResultEmail;
  253.     }
  254.     public function getSendOnlyErrors(): ?bool
  255.     {
  256.         return $this->sendOnlyErrors;
  257.     }
  258.     public function setSendOnlyErrors(?bool $sendOnlyErrors): void
  259.     {
  260.         $this->sendOnlyErrors $sendOnlyErrors;
  261.     }
  262.     public function isActive(): bool
  263.     {
  264.         return $this->isActive;
  265.     }
  266.     public function setIsActive(bool $isActive): void
  267.     {
  268.         $this->isActive $isActive;
  269.     }
  270.     public function getEnvironmentNotificationLevel(): ?string
  271.     {
  272.         return $this->environmentNotificationLevel;
  273.     }
  274.     public function setEnvironmentNotificationLevel(?string $environmentNotificationLevel): void
  275.     {
  276.         $this->environmentNotificationLevel $environmentNotificationLevel;
  277.     }
  278. }