<?php
namespace App\Entity;
use App\Repository\UserProfileRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: UserProfileRepository::class)]
class UserProfile
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\OneToOne(targetEntity: User::class, inversedBy: 'userProfile', cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
private $user;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $biography;
#[ORM\Column(type: 'string', length: 1000, nullable: true)]
private $picture;
#[ORM\Column(type: 'datetime', nullable: true)]
#[Assert\Date]
private $dateOfBirth;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $address;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $city;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $postalCode;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $country;
#[ORM\ManyToMany(targetEntity: Theme::class)]
private $themes;
#[ORM\Column(type: 'string', length: 1000, nullable: true)]
private $internalBiography;
#[ORM\Column(type: 'boolean', options: ['default' => 0])]
private $isPublic;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $phoneNumber;
public function __toString()
{
return 'profile: '.$this->user->getUsername();
}
public function __construct()
{
$this->themes = new ArrayCollection();
$this->isPublic = false;
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
public function getBiography(): ?string
{
return $this->biography;
}
public function setBiography(?string $biography): self
{
$this->biography = $biography;
return $this;
}
public function getDomains(): ?array
{
return $this->domains;
}
public function setDomains(array $domains): self
{
$this->domains = $domains;
return $this;
}
public function getPicture(): ?string
{
return $this->picture;
}
public function setPicture(?string $picture): self
{
$this->picture = $picture;
return $this;
}
public function getDateOfBirth(): ?\DateTimeInterface
{
return $this->dateOfBirth;
}
public function setDateOfBirth(?\DateTimeInterface $dateOfBirth): self
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postalCode;
}
public function setPostalCode(?string $postalCode): self
{
$this->postalCode = $postalCode;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
/**
* @return Collection|Theme[]
*/
public function getThemes(): Collection
{
return $this->themes;
}
public function setThemes(Collection $themes): self
{
if (count(
array_filter($themes->toArray(), function ($item) {
return !($item instanceof Theme);
})
) > 0) {
$this->themes = $themes;
}
return $this;
}
public function addTheme(Theme $theme): self
{
if (!$this->themes->contains($theme)) {
$this->themes[] = $theme;
}
return $this;
}
public function removeTheme(Theme $theme): self
{
$this->themes->removeElement($theme);
return $this;
}
public function getInternalBiography(): ?string
{
return $this->internalBiography;
}
public function setInternalBiography(?string $internalBiography): self
{
$this->internalBiography = $internalBiography;
return $this;
}
public function getIsPublic(): ?bool
{
return $this->isPublic;
}
public function setIsPublic(bool $isPublic): self
{
$this->isPublic = $isPublic;
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
}