src/Entity/Auth/User.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Auth;
  3. use App\Entity\Activities\Booking;
  4. use App\Entity\Activities\Feedback;
  5. use App\Entity\Activities\Message;
  6. use App\Entity\Activities\Report;
  7. use App\Entity\Activities\WareHouse;
  8. use App\Entity\Config\Day;
  9. use App\Entity\Config\Profile;
  10. use App\Entity\Activities\Likes;
  11. use App\Entity\Config\Services;
  12. use App\Infrastructure\Social\Entity\SocialLoggableTrait;
  13. use App\Repository\Auth\UserRepository;
  14. use App\Traits\DeletableTrait;
  15. use App\Traits\FilesTrait;
  16. use App\Traits\ProfileTrait;
  17. use App\Traits\TimestampsTrait;
  18. use DateTime;
  19. use DateTimeInterface;
  20. use Doctrine\Common\Collections\ArrayCollection;
  21. use Doctrine\Common\Collections\Collection;
  22. use Doctrine\ORM\Mapping as ORM;
  23. use Serializable;
  24. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  25. use Symfony\Component\HttpFoundation\File\File;
  26. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  27. use Symfony\Component\Security\Core\User\UserInterface;
  28. use Symfony\Component\Validator\Constraints as Assert;
  29. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  30. /**
  31.  * @ORM\Entity(repositoryClass=UserRepository::class)
  32.  * @UniqueEntity(fields={"email"}, message="Il y'a déjà un compte avec cette addresse email")
  33.  * @ORM\HasLifecycleCallbacks()
  34.  * @Vich\Uploadable()
  35.  */
  36. class User implements UserInterfacePasswordAuthenticatedUserInterfaceSerializable
  37. {
  38.     use TimestampsTrait;
  39.     use DeletableTrait;
  40.     use SocialLoggableTrait;
  41.     use ProfileTrait;
  42.     use FilesTrait;
  43.     /**
  44.      * @ORM\Id
  45.      * @ORM\GeneratedValue
  46.      * @ORM\Column(type="integer")
  47.      */
  48.     private int $id;
  49.     /**
  50.      * @ORM\Column(type="string", length=180, unique=true)
  51.      */
  52.     private string $email;
  53.     /**
  54.      * @ORM\Column(type="json")
  55.      */
  56.     private array $roles = ['ROLE_USER'];
  57.     /**
  58.      * @ORM\Column(type="json", nullable=true)
  59.      */
  60.     private ?array $errors;
  61.     /**
  62.      * @var string The hashed password
  63.      * @ORM\Column(type="string")
  64.      */
  65.     private string $password;
  66.     /**
  67.      * @ORM\Column(type="string", length=255)
  68.      */
  69.     private string $firstname;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      */
  73.     private ?string $lastname;
  74.     /**
  75.      * @ORM\Column(type="string", length=255)
  76.      */
  77.     private string $phone '';
  78.     /**
  79.      * @ORM\Column(type="string", length=255)
  80.      */
  81.     private string $address '';
  82.     /**
  83.      * @ORM\Column(type="integer", nullable=true)
  84.      * @Assert\Regex("/^\d{5}$/")
  85.      */
  86.     private ?int $zipCode null;
  87.     /**
  88.      * @ORM\Column(type="string", length=255)
  89.      */
  90.     private string $town '';
  91.     /**
  92.      * @ORM\Column(type="string", length=100, nullable=true)
  93.      */
  94.     private ?string $username;
  95.     /**
  96.      * @ORM\Column(type="string", length=255, nullable=true)
  97.      */
  98.     private ?string $confirmationToken;
  99.     /**
  100.      * @ORM\Column(type="boolean")
  101.      */
  102.     private bool $isVerified false;
  103.     /**
  104.      * @ORM\Column(type="boolean", options={"default": true})
  105.      */
  106.     private bool $offerMailNotification true;
  107.     /**
  108.      * @ORM\Column(type="text", nullable=true)
  109.      */
  110.     private ?string $biography;
  111.     /**
  112.      * @Vich\UploadableField(mapping="avatars", fileNameProperty="avatarName")
  113.      * @var File|null
  114.      */
  115.     private ?File $avatarFile null;
  116.     /**
  117.      * @ORM\Column(type="string", length=255, nullable=true)
  118.      */
  119.     private ?string $avatarName null;
  120.     /**
  121.      * @ORM\OneToMany(targetEntity=Day::class, mappedBy="user")
  122.      */
  123.     private $days;
  124.     /**
  125.      * @ORM\Column(type="float")
  126.      */
  127.     private float $hourRate 0;
  128.     /**
  129.      * @ORM\Column(type="smallint")
  130.      */
  131.     private int $experience 0;
  132.     /**
  133.      * @ORM\Column(type="date", nullable=true)
  134.      */
  135.     private ?DateTime $birthDate;
  136.     /**
  137.      * @ORM\Column(type="boolean")
  138.      */
  139.     private bool $vehicle false;
  140.     /**
  141.      * @ORM\Column(type="string", length=50, nullable=true)
  142.      */
  143.     private ?string $status;
  144.     /**
  145.      * @ORM\ManyToOne(targetEntity=Profile::class, inversedBy="users")
  146.      */
  147.     private ?Profile $profile;
  148.     /**
  149.      * @ORM\OneToMany(targetEntity=Feedback::class, mappedBy="author")
  150.      */
  151.     private $feedback;
  152.     /**
  153.      * @ORM\OneToMany(targetEntity=Feedback::class, mappedBy="candidate")
  154.      */
  155.     private $candidateFeedback;
  156.     /**
  157.      * @ORM\OneToMany(targetEntity=Likes::class, mappedBy="liker")
  158.      */
  159.     private $likerLikes;
  160.     /**
  161.      * @ORM\OneToMany(targetEntity=Likes::class, mappedBy="liked")
  162.      */
  163.     private $likedLikes;
  164.     /**
  165.      * @ORM\OneToMany(targetEntity=Report::class, mappedBy="author")
  166.      */
  167.     private $reports;
  168.     /**
  169.      * @ORM\OneToMany(targetEntity=Report::class, mappedBy="profile")
  170.      */
  171.     private $profileReports;
  172.     /**
  173.      * @ORM\OneToMany(targetEntity=Booking::class, mappedBy="parent")
  174.      */
  175.     private $parentBookings;
  176.     /**
  177.      * @ORM\OneToMany(targetEntity=Booking::class, mappedBy="nanny")
  178.      */
  179.     private $bookings;
  180.     /**
  181.      * @ORM\OneToMany(targetEntity=Message::class, mappedBy="sender")
  182.      */
  183.     private $senderMessages;
  184.     /**
  185.      * @ORM\OneToMany(targetEntity=Message::class, mappedBy="recipient")
  186.      */
  187.     private $recipientMessages;
  188.     /**
  189.      * @ORM\ManyToMany(targetEntity=Services::class, inversedBy="users")
  190.      */
  191.     private $services;
  192.     /**
  193.      * @ORM\Column(type="json", nullable=true)
  194.      */
  195.     private $validations = [];
  196.     /**
  197.      * @ORM\Column(type="date", nullable=true)
  198.      */
  199.     private $hiredAt;
  200.     /**
  201.      * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  202.      */
  203.     private $matricule;
  204.     /**
  205.      * @ORM\ManyToOne(targetEntity=WareHouse::class, inversedBy="users")
  206.      */
  207.     private $warehouse;
  208.     /**
  209.      * @ORM\Column(type="boolean")
  210.      */
  211.     private $isPasswordUpdated false;
  212.     public function __construct()
  213.     {
  214.         $this->days = new ArrayCollection();
  215.         $this->feedback = new ArrayCollection();
  216.         $this->candidateFeedback = new ArrayCollection();
  217.         $this->likerLikes = new ArrayCollection();
  218.         $this->likedLikes = new ArrayCollection();
  219.         $this->reports = new ArrayCollection();
  220.         $this->profileReports = new ArrayCollection();
  221.         $this->parentBookings = new ArrayCollection();
  222.         $this->bookings = new ArrayCollection();
  223.         $this->senderMessages = new ArrayCollection();
  224.         $this->recipientMessages = new ArrayCollection();
  225.         $this->services = new ArrayCollection();
  226.     }
  227.     /**
  228.      * @return string|null
  229.      */
  230.     public function getFullName()
  231.     {
  232.         $name '';
  233.         if (!empty($this->firstname)) {
  234.             $name .= $this->firstname;
  235.         }
  236.         if (!empty($this->lastname)) {
  237.             $name .= !empty($name) ? ' ' $this->lastname $this->lastname;
  238.         }
  239.         return !empty($name) ? $name null;
  240.     }
  241.     /**
  242.      * @return string|null
  243.      */
  244.     public function getFullAddress()
  245.     {
  246.         $address '';
  247.         if (!empty($this->address)) {
  248.             $address .= $this->address;
  249.         }
  250.         if (!empty($this->zipCode)) {
  251.             $address .= (!empty($address)) ? ', ' $this->zipCode $this->zipCode;
  252.         }
  253.         if (!empty($this->zipCode)) {
  254.             $address .= (!empty($address)) ? ', ' $this->town $this->town;
  255.         }
  256.         return (!empty($address)) ? $address null;
  257.     }
  258.     public function __toString()
  259.     {
  260.         return $this->getFullName();
  261.     }
  262.     /**
  263.      * Permet de savoir si cet article est "liké" par un utilisateur
  264.      * @param User|UserInterface $user
  265.      * @return bool
  266.      */
  267.     public function isLikeByUser(User $user): bool
  268.     {
  269.         foreach ($this->likedLikes as $like) {
  270.             /* @var $like Likes */
  271.             if ($like->getLiker() === $user && $like->isIsActive() === true) return true;
  272.         }
  273.         return false;
  274.     }
  275.     public function getId(): ?int
  276.     {
  277.         return $this->id;
  278.     }
  279.     public function getEmail(): ?string
  280.     {
  281.         return $this->email;
  282.     }
  283.     public function setEmail(string $email): self
  284.     {
  285.         $this->email $email;
  286.         return $this;
  287.     }
  288.     /**
  289.      * A visual identifier that represents this user.
  290.      *
  291.      * @see UserInterface
  292.      */
  293.     public function getUserIdentifier(): string
  294.     {
  295.         return (string)$this->getFullName();
  296.     }
  297.     /**
  298.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  299.      */
  300.     public function getUsername(): string
  301.     {
  302.         return (string)$this->email;
  303.     }
  304.     /**
  305.      * @see UserInterface
  306.      */
  307.     public function getRoles(): array
  308.     {
  309.         $roles $this->roles;
  310.         // guarantee every user at least has ROLE_USER
  311.         $roles[] = 'ROLE_USER';
  312.         return array_unique($roles);
  313.     }
  314.     public function setRoles(array $roles): self
  315.     {
  316.         $this->roles $roles;
  317.         return $this;
  318.     }
  319.     /**
  320.      * @see PasswordAuthenticatedUserInterface
  321.      */
  322.     public function getPassword(): string
  323.     {
  324.         return $this->password;
  325.     }
  326.     public function setPassword(string $password): self
  327.     {
  328.         $this->password $password;
  329.         return $this;
  330.     }
  331.     /**
  332.      * Returning a salt is only needed, if you are not using a modern
  333.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  334.      *
  335.      * @see UserInterface
  336.      */
  337.     public function getSalt(): ?string
  338.     {
  339.         return null;
  340.     }
  341.     /**
  342.      * @see UserInterface
  343.      */
  344.     public function eraseCredentials()
  345.     {
  346.         // If you store any temporary, sensitive data on the user, clear it here
  347.         // $this->plainPassword = null;
  348.     }
  349.     public function getFirstname(): ?string
  350.     {
  351.         return $this->firstname;
  352.     }
  353.     public function setFirstname(string $firstname): self
  354.     {
  355.         $this->firstname $firstname;
  356.         return $this;
  357.     }
  358.     public function getLastname(): ?string
  359.     {
  360.         return $this->lastname;
  361.     }
  362.     public function setLastname(?string $lastname): self
  363.     {
  364.         $this->lastname $lastname;
  365.         return $this;
  366.     }
  367.     public function getPhone(): ?string
  368.     {
  369.         return $this->phone;
  370.     }
  371.     public function setPhone(string $phone): self
  372.     {
  373.         $this->phone $phone;
  374.         return $this;
  375.     }
  376.     public function getAddress(): ?string
  377.     {
  378.         return $this->address;
  379.     }
  380.     public function setAddress(string $address): self
  381.     {
  382.         $this->address $address;
  383.         return $this;
  384.     }
  385.     public function getZipCode(): ?int
  386.     {
  387.         return $this->zipCode;
  388.     }
  389.     public function setZipCode(int $zipCode): self
  390.     {
  391.         $this->zipCode $zipCode;
  392.         return $this;
  393.     }
  394.     public function getTown(): ?string
  395.     {
  396.         return $this->town;
  397.     }
  398.     public function setTown(string $town): self
  399.     {
  400.         $this->town $town;
  401.         return $this;
  402.     }
  403.     public function setUsername(?string $username): self
  404.     {
  405.         $this->username $username;
  406.         return $this;
  407.     }
  408.     public function getConfirmationToken(): ?string
  409.     {
  410.         return $this->confirmationToken;
  411.     }
  412.     public function setConfirmationToken(?string $confirmationToken): self
  413.     {
  414.         $this->confirmationToken $confirmationToken;
  415.         return $this;
  416.     }
  417.     public function isVerified(): bool
  418.     {
  419.         return $this->isVerified;
  420.     }
  421.     public function setIsVerified(bool $isVerified): self
  422.     {
  423.         $this->isVerified $isVerified;
  424.         return $this;
  425.     }
  426.     public function hasOfferMailNotification(): bool
  427.     {
  428.         return $this->offerMailNotification;
  429.     }
  430.     public function setOfferMailNotification(bool $offerMailNotification): User
  431.     {
  432.         $this->offerMailNotification $offerMailNotification;
  433.         return $this;
  434.     }
  435.     public function getBiography(): ?string
  436.     {
  437.         return $this->biography;
  438.     }
  439.     public function setBiography(?string $biography): self
  440.     {
  441.         $this->biography $biography;
  442.         return $this;
  443.     }
  444.     public function getAvatarFile(): ?File
  445.     {
  446.         return $this->avatarFile;
  447.     }
  448.     public function setAvatarFile(?File $avatarFile): User
  449.     {
  450.         $this->avatarFile $avatarFile;
  451.         return $this;
  452.     }
  453.     public function getAvatarName(): ?string
  454.     {
  455.         return $this->avatarName;
  456.     }
  457.     public function setAvatarName(?string $avatarName): User
  458.     {
  459.         $this->avatarName $avatarName;
  460.         return $this;
  461.     }
  462.     /**
  463.      * @return Collection<int, Day>
  464.      */
  465.     public function getDays(): Collection
  466.     {
  467.         return $this->days;
  468.     }
  469.     /**
  470.      * @return Day[]
  471.      */
  472.     public function getAvailableDays(): array
  473.     {
  474.         $days $this->days->getValues();
  475.         $result = [];
  476.         /* @var $day Day */
  477.         foreach ($days as $day) {
  478.             if ($day->isIsOpen()) {
  479.                 $result[] = $day;
  480.             }
  481.         }
  482.         return $result;
  483.     }
  484.     public function addDay(Day $day): self
  485.     {
  486.         if (!$this->days->contains($day)) {
  487.             $this->days[] = $day;
  488.             $day->setUser($this);
  489.         }
  490.         return $this;
  491.     }
  492.     public function removeDay(Day $day): self
  493.     {
  494.         if ($this->days->removeElement($day)) {
  495.             // set the owning side to null (unless already changed)
  496.             if ($day->getUser() === $this) {
  497.                 $day->setUser(null);
  498.             }
  499.         }
  500.         return $this;
  501.     }
  502.     public function getHourRate(): ?float
  503.     {
  504.         return $this->hourRate;
  505.     }
  506.     public function setHourRate(float $hourRate): self
  507.     {
  508.         $this->hourRate $hourRate;
  509.         return $this;
  510.     }
  511.     public function getExperience(): ?int
  512.     {
  513.         return $this->experience;
  514.     }
  515.     public function setExperience(int $experience): self
  516.     {
  517.         $this->experience $experience;
  518.         return $this;
  519.     }
  520.     public function getBirthDate(): ?DateTimeInterface
  521.     {
  522.         return $this->birthDate;
  523.     }
  524.     public function setBirthDate(?DateTimeInterface $birthDate): self
  525.     {
  526.         $this->birthDate $birthDate;
  527.         return $this;
  528.     }
  529.     public function isVehicle(): ?bool
  530.     {
  531.         return $this->vehicle;
  532.     }
  533.     public function setVehicle(bool $vehicle): self
  534.     {
  535.         $this->vehicle $vehicle;
  536.         return $this;
  537.     }
  538.     public function getStatus(): ?string
  539.     {
  540.         return $this->status;
  541.     }
  542.     public function setStatus(?string $status): self
  543.     {
  544.         $this->status $status;
  545.         return $this;
  546.     }
  547.     public function getProfile(): ?Profile
  548.     {
  549.         return $this->profile;
  550.     }
  551.     public function setProfile(?Profile $profile): self
  552.     {
  553.         $this->profile $profile;
  554.         return $this;
  555.     }
  556.     /**
  557.      * @return Collection<int, Feedback>
  558.      */
  559.     public function getFeedback(): Collection
  560.     {
  561.         return $this->feedback;
  562.     }
  563.     public function addFeedback(Feedback $feedback): self
  564.     {
  565.         if (!$this->feedback->contains($feedback)) {
  566.             $this->feedback[] = $feedback;
  567.             $feedback->setAuthor($this);
  568.         }
  569.         return $this;
  570.     }
  571.     public function removeFeedback(Feedback $feedback): self
  572.     {
  573.         if ($this->feedback->removeElement($feedback)) {
  574.             // set the owning side to null (unless already changed)
  575.             if ($feedback->getAuthor() === $this) {
  576.                 $feedback->setAuthor(null);
  577.             }
  578.         }
  579.         return $this;
  580.     }
  581.     /**
  582.      * @return Collection<int, Feedback>
  583.      */
  584.     public function getCandidateFeedback(): Collection
  585.     {
  586.         return $this->candidateFeedback;
  587.     }
  588.     public function addCandidateFeedback(Feedback $candidateFeedback): self
  589.     {
  590.         if (!$this->candidateFeedback->contains($candidateFeedback)) {
  591.             $this->candidateFeedback[] = $candidateFeedback;
  592.             $candidateFeedback->setCandidate($this);
  593.         }
  594.         return $this;
  595.     }
  596.     public function removeCandidateFeedback(Feedback $candidateFeedback): self
  597.     {
  598.         if ($this->candidateFeedback->removeElement($candidateFeedback)) {
  599.             // set the owning side to null (unless already changed)
  600.             if ($candidateFeedback->getCandidate() === $this) {
  601.                 $candidateFeedback->setCandidate(null);
  602.             }
  603.         }
  604.         return $this;
  605.     }
  606.     /**
  607.      * @return Collection<int, Likes>
  608.      */
  609.     public function getLikerLikes(): Collection
  610.     {
  611.         return $this->likerLikes;
  612.     }
  613.     public function addLikerLike(Likes $likerLike): self
  614.     {
  615.         if (!$this->likerLikes->contains($likerLike)) {
  616.             $this->likerLikes[] = $likerLike;
  617.             $likerLike->setLiker($this);
  618.         }
  619.         return $this;
  620.     }
  621.     public function removeLikerLike(Likes $likerLike): self
  622.     {
  623.         if ($this->likerLikes->removeElement($likerLike)) {
  624.             // set the owning side to null (unless already changed)
  625.             if ($likerLike->getLiker() === $this) {
  626.                 $likerLike->setLiker(null);
  627.             }
  628.         }
  629.         return $this;
  630.     }
  631.     /**
  632.      * @return Collection<int, Likes>
  633.      */
  634.     public function getLikedLikes(): Collection
  635.     {
  636.         return $this->likedLikes;
  637.     }
  638.     public function addLikedLike(Likes $likedLike): self
  639.     {
  640.         if (!$this->likedLikes->contains($likedLike)) {
  641.             $this->likedLikes[] = $likedLike;
  642.             $likedLike->setLiked($this);
  643.         }
  644.         return $this;
  645.     }
  646.     public function removeLikedLike(Likes $likedLike): self
  647.     {
  648.         if ($this->likedLikes->removeElement($likedLike)) {
  649.             // set the owning side to null (unless already changed)
  650.             if ($likedLike->getLiked() === $this) {
  651.                 $likedLike->setLiked(null);
  652.             }
  653.         }
  654.         return $this;
  655.     }
  656.     /**
  657.      * @return Collection<int, Report>
  658.      */
  659.     public function getReports(): Collection
  660.     {
  661.         return $this->reports;
  662.     }
  663.     public function addReport(Report $report): self
  664.     {
  665.         if (!$this->reports->contains($report)) {
  666.             $this->reports[] = $report;
  667.             $report->setAuthor($this);
  668.         }
  669.         return $this;
  670.     }
  671.     public function removeReport(Report $report): self
  672.     {
  673.         if ($this->reports->removeElement($report)) {
  674.             // set the owning side to null (unless already changed)
  675.             if ($report->getAuthor() === $this) {
  676.                 $report->setAuthor(null);
  677.             }
  678.         }
  679.         return $this;
  680.     }
  681.     /**
  682.      * @return Collection<int, Report>
  683.      */
  684.     public function getProfileReports(): Collection
  685.     {
  686.         return $this->profileReports;
  687.     }
  688.     public function addProfileReport(Report $profileReport): self
  689.     {
  690.         if (!$this->profileReports->contains($profileReport)) {
  691.             $this->profileReports[] = $profileReport;
  692.             $profileReport->setProfile($this);
  693.         }
  694.         return $this;
  695.     }
  696.     public function removeProfileReport(Report $profileReport): self
  697.     {
  698.         if ($this->profileReports->removeElement($profileReport)) {
  699.             // set the owning side to null (unless already changed)
  700.             if ($profileReport->getProfile() === $this) {
  701.                 $profileReport->setProfile(null);
  702.             }
  703.         }
  704.         return $this;
  705.     }
  706.     /**
  707.      * @return Collection<int, Booking>
  708.      */
  709.     public function getParentBookings(): Collection
  710.     {
  711.         return $this->parentBookings;
  712.     }
  713.     public function addParentBooking(Booking $parentBooking): self
  714.     {
  715.         if (!$this->parentBookings->contains($parentBooking)) {
  716.             $this->parentBookings[] = $parentBooking;
  717.             $parentBooking->setParent($this);
  718.         }
  719.         return $this;
  720.     }
  721.     public function removeParentBooking(Booking $parentBooking): self
  722.     {
  723.         if ($this->parentBookings->removeElement($parentBooking)) {
  724.             // set the owning side to null (unless already changed)
  725.             if ($parentBooking->getParent() === $this) {
  726.                 $parentBooking->setParent(null);
  727.             }
  728.         }
  729.         return $this;
  730.     }
  731.     /**
  732.      * @return Collection<int, Booking>
  733.      */
  734.     public function getBookings(): Collection
  735.     {
  736.         return $this->bookings;
  737.     }
  738.     public function addBooking(Booking $booking): self
  739.     {
  740.         if (!$this->bookings->contains($booking)) {
  741.             $this->bookings[] = $booking;
  742.             $booking->setNanny($this);
  743.         }
  744.         return $this;
  745.     }
  746.     public function removeBooking(Booking $booking): self
  747.     {
  748.         if ($this->bookings->removeElement($booking)) {
  749.             // set the owning side to null (unless already changed)
  750.             if ($booking->getNanny() === $this) {
  751.                 $booking->setNanny(null);
  752.             }
  753.         }
  754.         return $this;
  755.     }
  756.     /**
  757.      * String representation of object
  758.      * @link http://php.net/manual/en/serializable.serialize.php
  759.      * @return string the string representation of the object or null
  760.      * @since 5.1.0
  761.      */
  762.     public function serialize()
  763.     {
  764.         return serialize([$this->id$this->firstname$this->lastname$this->email$this->passwordbase64_encode($this->avatarFile)]);
  765.     }
  766.     /**
  767.      * Constructs the object
  768.      * @link http://php.net/manual/en/serializable.unserialize.php
  769.      *
  770.      * @param string $serialized <p>
  771.      * The string representation of the object.
  772.      * </p>
  773.      *
  774.      * @return void
  775.      * @since 5.1.0
  776.      */
  777.     public function unserialize($serialized)
  778.     {
  779.         if ($this->avatarFile) {
  780.             [$this->id$this->firstname$this->lastname$this->email$this->password$this->avatarFile] = unserialize($serialized, ['allowed_classes' => false]);
  781.         } else {
  782.             [$this->id$this->firstname$this->lastname$this->email$this->password] = unserialize($serialized, ['allowed_classes' => false]);
  783.         }
  784.     }
  785.     /**
  786.      * @return Collection<int, Message>
  787.      */
  788.     public function getSenderMessages(): Collection
  789.     {
  790.         return $this->senderMessages;
  791.     }
  792.     public function addSenderMessage(Message $senderMessage): self
  793.     {
  794.         if (!$this->senderMessages->contains($senderMessage)) {
  795.             $this->senderMessages[] = $senderMessage;
  796.             $senderMessage->setSender($this);
  797.         }
  798.         return $this;
  799.     }
  800.     public function removeSenderMessage(Message $senderMessage): self
  801.     {
  802.         if ($this->senderMessages->removeElement($senderMessage)) {
  803.             // set the owning side to null (unless already changed)
  804.             if ($senderMessage->getSender() === $this) {
  805.                 $senderMessage->setSender(null);
  806.             }
  807.         }
  808.         return $this;
  809.     }
  810.     /**
  811.      * @return Collection<int, Message>
  812.      */
  813.     public function getRecipientMessages(): Collection
  814.     {
  815.         return $this->recipientMessages;
  816.     }
  817.     public function addRecipientMessage(Message $recipientMessage): self
  818.     {
  819.         if (!$this->recipientMessages->contains($recipientMessage)) {
  820.             $this->recipientMessages[] = $recipientMessage;
  821.             $recipientMessage->setRecipient($this);
  822.         }
  823.         return $this;
  824.     }
  825.     public function removeRecipientMessage(Message $recipientMessage): self
  826.     {
  827.         if ($this->recipientMessages->removeElement($recipientMessage)) {
  828.             // set the owning side to null (unless already changed)
  829.             if ($recipientMessage->getRecipient() === $this) {
  830.                 $recipientMessage->setRecipient(null);
  831.             }
  832.         }
  833.         return $this;
  834.     }
  835.     /**
  836.      * @return Collection<int, Services>
  837.      */
  838.     public function getServices(): Collection
  839.     {
  840.         return $this->services;
  841.     }
  842.     public function addService(Services $service): self
  843.     {
  844.         if (!$this->services->contains($service)) {
  845.             $this->services[] = $service;
  846.         }
  847.         return $this;
  848.     }
  849.     public function removeService(Services $service): self
  850.     {
  851.         $this->services->removeElement($service);
  852.         return $this;
  853.     }
  854.     /**
  855.      * @see UserInterface|null
  856.      */
  857.     public function getErrors(): ?array
  858.     {
  859.         return $this->errors;
  860.     }
  861.     /**
  862.      * @param array|null $errors
  863.      * @return $this
  864.      */
  865.     public function setErrors(array $errors null): self
  866.     {
  867.         $this->errors $errors;
  868.         return $this;
  869.     }
  870.     public function getValidations(): ?array
  871.     {
  872.         return $this->validations;
  873.     }
  874.     public function setValidations(?array $validations): self
  875.     {
  876.         $this->validations $validations;
  877.         return $this;
  878.     }
  879.     public function getHiredAt(): ?DateTimeInterface
  880.     {
  881.         return $this->hiredAt;
  882.     }
  883.     public function setHiredAt(?DateTimeInterface $hiredAt): self
  884.     {
  885.         $this->hiredAt $hiredAt;
  886.         return $this;
  887.     }
  888.     public function getMatricule(): ?string
  889.     {
  890.         return $this->matricule;
  891.     }
  892.     public function setMatricule(?string $matricule): self
  893.     {
  894.         $this->matricule $matricule;
  895.         return $this;
  896.     }
  897.     public function getWarehouse(): ?WareHouse
  898.     {
  899.         return $this->warehouse;
  900.     }
  901.     public function setWarehouse(?WareHouse $warehouse): self
  902.     {
  903.         $this->warehouse $warehouse;
  904.         return $this;
  905.     }
  906.     public function isIsPasswordUpdated(): ?bool
  907.     {
  908.         return $this->isPasswordUpdated;
  909.     }
  910.     public function setIsPasswordUpdated(bool $isPasswordUpdated): self
  911.     {
  912.         $this->isPasswordUpdated $isPasswordUpdated;
  913.         return $this;
  914.     }
  915. }