src/Entity/Referee.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Repository\RefereeRepository;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. /**
  11.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  12.  */
  13. #[ORM\Entity(repositoryClassRefereeRepository::class)]
  14. class Referee implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\Column(type'string'length180uniquetrue)]
  21.     private $email;
  22.     #[ORM\Column(type'json')]
  23.     private $roles = [];
  24.     #[ORM\Column(type'string')]
  25.     private $password;
  26.     #[ORM\Column(type'string'length255)]
  27.     private $firstname;
  28.     #[ORM\Column(type'string'length255)]
  29.     private $lastname;
  30.     #[ORM\Column(type'string'length255nullabletrue)]
  31.     private $avatar;
  32.     #[ORM\Column(type'date'nullabletrue)]
  33.     private $birthday;
  34.     #[ORM\Column(type'boolean')]
  35.     private $gender;
  36.     #[ORM\Column(type'string'length255)]
  37.     private $phone1;
  38.     #[ORM\Column(type'string'length255nullabletrue)]
  39.     private $phone2;
  40.     #[ORM\Column(type'string'length255nullabletrue)]
  41.     private $kyorugiNumber;
  42.     #[ORM\Column(type'string'length255nullabletrue)]
  43.     private $poomsaeNumber;
  44.     #[ORM\Column(type'string'length255nullabletrue)]
  45.     private $kyorugiClass;
  46.     #[ORM\Column(type'string'length255nullabletrue)]
  47.     private $poomsaeClass;
  48.     #[ORM\Column(type'string'length255nullabletrue)]
  49.     private $kyorugiIRCard;
  50.     #[ORM\Column(type'string'length255nullabletrue)]
  51.     private $poomsaeIRCard;
  52.     #[ORM\Column(type'datetime_immutable')]
  53.     private $createdAt;
  54.     #[ORM\ManyToOne(targetEntityCountry::class, inversedBy'referees')]
  55.     private $country;
  56.     #[ORM\Column(type'boolean')]
  57.     private $isVerified false;
  58.     #[ORM\OneToMany(mappedBy'referee'targetEntityAttribution::class)]
  59.     private $attributions;
  60.     #[ORM\Column(type'boolean')]
  61.     private $active;
  62.     #[ORM\ManyToOne(targetEntityCountry::class, inversedBy'refereessecond')]
  63.     private $secondcountry;
  64.     public function __construct()
  65.     {
  66.         $this->createdAt = new \DateTimeImmutable();
  67.         $this->attributions = new ArrayCollection();
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getEmail(): ?string
  74.     {
  75.         return $this->email;
  76.     }
  77.     public function setEmail(string $email): self
  78.     {
  79.         $this->email $email;
  80.         return $this;
  81.     }
  82.     /**
  83.      * A visual identifier that represents this user.
  84.      *
  85.      * @see UserInterface
  86.      */
  87.     public function getUserIdentifier(): string
  88.     {
  89.         return (string) $this->email;
  90.     }
  91.     /**
  92.      * @see UserInterface
  93.      */
  94.     public function getRoles(): array
  95.     {
  96.         $roles $this->roles;
  97.         // guarantee every user at least has ROLE_USER
  98.         $roles[] = 'ROLE_USER';
  99.         return array_unique($roles);
  100.     }
  101.     public function setRoles(array $roles): self
  102.     {
  103.         $this->roles $roles;
  104.         return $this;
  105.     }
  106.     public function addRole(string $role): self
  107.     {
  108.         $this->roles[] = $role;
  109.         $this->roles array_unique($this->roles);
  110.         return $this;
  111.     }
  112.     public function isAdmin(): bool
  113.     {
  114.         return in_array("ROLE_ADMIN"$this->roles);
  115.     }
  116.     public function isReferee(): bool
  117.     {
  118.         return in_array("ROLE_REFEREE"$this->roles);
  119.     }
  120.     /**
  121.      * @see PasswordAuthenticatedUserInterface
  122.      */
  123.     public function getPassword(): string
  124.     {
  125.         return $this->password;
  126.     }
  127.     public function setPassword(string $password): self
  128.     {
  129.         $this->password $password;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @see UserInterface
  134.      */
  135.     public function eraseCredentials()
  136.     {
  137.         // If you store any temporary, sensitive data on the user, clear it here
  138.         // $this->plainPassword = null;
  139.     }
  140.     public function getFirstname(): ?string
  141.     {
  142.         return $this->firstname;
  143.     }
  144.     public function setFirstname(string $firstname): self
  145.     {
  146.         $this->firstname $firstname;
  147.         return $this;
  148.     }
  149.     public function getLastname(): ?string
  150.     {
  151.         return $this->lastname;
  152.     }
  153.     public function setLastname(string $lastname): self
  154.     {
  155.         $this->lastname $lastname;
  156.         return $this;
  157.     }
  158.     public function getAvatar(): ?string
  159.     {   
  160.         return $this->avatar;
  161.     }
  162.     public function setAvatar(?string $avatar): self
  163.     {
  164.         $this->avatar $avatar;
  165.         return $this;
  166.     }
  167.     public function getAge()
  168.     {
  169.         if (null === $this->getBirthday()) {
  170.             return NULL;
  171.         } else {
  172.             $now = new \DateTime('now');
  173.             $age $this->getBirthday();
  174.             $difference $now->diff($age);
  175.             return $difference->format('%y years');
  176.         }
  177.     }
  178.     public function getBirthday(): ?\DateTimeInterface
  179.     {
  180.         return $this->birthday;
  181.     }
  182.     public function setBirthday(?\DateTimeInterface $birthday): self
  183.     {
  184.         $this->birthday $birthday;
  185.         return $this;
  186.     }
  187.     public function getGender(): ?bool
  188.     {
  189.         return $this->gender;
  190.     }
  191.     public function setGender(bool $gender): self
  192.     {
  193.         $this->gender $gender;
  194.         return $this;
  195.     }
  196.     public function getPhone1(): ?string
  197.     {
  198.         return $this->phone1;
  199.     }
  200.     public function setPhone1(string $phone1): self
  201.     {
  202.         $this->phone1 $phone1;
  203.         return $this;
  204.     }
  205.     public function getPhone2(): ?string
  206.     {
  207.         return $this->phone2;
  208.     }
  209.     public function setPhone2(?string $phone2): self
  210.     {
  211.         $this->phone2 $phone2;
  212.         return $this;
  213.     }
  214.     public function getKyorugiNumber(): ?string
  215.     {
  216.         return $this->kyorugiNumber;
  217.     }
  218.     public function setKyorugiNumber(?string $kyorugiNumber): self
  219.     {
  220.         $this->kyorugiNumber $kyorugiNumber;
  221.         return $this;
  222.     }
  223.     public function getPoomsaeNumber(): ?string
  224.     {
  225.         return $this->poomsaeNumber;
  226.     }
  227.     public function setPoomsaeNumber(?string $poomsaeNumber): self
  228.     {
  229.         $this->poomsaeNumber $poomsaeNumber;
  230.         return $this;
  231.     }
  232.     public function getKyorugiClass(): ?string
  233.     {
  234.         return $this->kyorugiClass;
  235.     }
  236.     public function setKyorugiClass(?string $kyorugiClass): self
  237.     {
  238.         $this->kyorugiClass $kyorugiClass;
  239.         return $this;
  240.     }
  241.     public function getPoomsaeClass(): ?string
  242.     {
  243.         return $this->poomsaeClass;
  244.     }
  245.     public function setPoomsaeClass(?string $poomsaeClass): self
  246.     {
  247.         $this->poomsaeClass $poomsaeClass;
  248.         return $this;
  249.     }
  250.     public function getKyorugiIRCard(): ?string
  251.     {
  252.         return $this->kyorugiIRCard;
  253.     }
  254.     public function setKyorugiIRCard(?string $kyorugiIRCard): self
  255.     {
  256.         $this->kyorugiIRCard $kyorugiIRCard;
  257.         return $this;
  258.     }
  259.     public function getCreatedAt(): ?\DateTimeImmutable
  260.     {
  261.         return $this->createdAt;
  262.     }
  263.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  264.     {
  265.         $this->createdAt $createdAt;
  266.         return $this;
  267.     }
  268.     public function getCountry(): ?Country
  269.     {
  270.         return $this->country;
  271.     }
  272.     public function setCountry(?Country $country): self
  273.     {
  274.         $this->country $country;
  275.         return $this;
  276.     }
  277.     public function isVerified(): bool
  278.     {
  279.         return $this->isVerified;
  280.     }
  281.     public function setIsVerified(bool $isVerified): self
  282.     {
  283.         $this->isVerified $isVerified;
  284.         return $this;
  285.     }
  286.     /**
  287.      * @return Collection|Attribution[]
  288.      */
  289.     public function getAttributions(): Collection
  290.     {
  291.         return $this->attributions;
  292.     }
  293.     public function addAttribution(Attribution $attribution): self
  294.     {
  295.         if (!$this->attributions->contains($attribution)) {
  296.             $this->attributions[] = $attribution;
  297.             $attribution->setReferee($this);
  298.         }
  299.         return $this;
  300.     }
  301.     public function removeAttribution(Attribution $attribution): self
  302.     {
  303.         if ($this->attributions->removeElement($attribution)) {
  304.             // set the owning side to null (unless already changed)
  305.             if ($attribution->getReferee() === $this) {
  306.                 $attribution->setReferee(null);
  307.             }
  308.         }
  309.         return $this;
  310.     }
  311.     public function __toString()
  312.     {
  313.         return $this->firstname.' '.$this->lastname;
  314.     }
  315.     public function getActive(): ?bool
  316.     {
  317.         return $this->active;
  318.     }
  319.     public function setActive(bool $active): self
  320.     {
  321.         $this->active $active;
  322.         return $this;
  323.     }
  324.     public function getSecondcountry(): ?Country
  325.     {
  326.         return $this->secondcountry;
  327.     }
  328.     public function setSecondcountry(?Country $secondcountry): self
  329.     {
  330.         $this->secondcountry $secondcountry;
  331.         return $this;
  332.     }
  333.     public function getPoomsaeIRCard(): ?string
  334.     {
  335.         return $this->poomsaeIRCard;
  336.     }
  337.     public function setPoomsaeIRCard(?string $poomsaeIRCard): self
  338.     {
  339.         $this->poomsaeIRCard $poomsaeIRCard;
  340.         return $this;
  341.     }
  342. }