<?php
namespace App\Entity;
use App\Entity\SuperClass\BaseEntity;
use App\Repository\AddressRepository;
use App\Validator\IsValidOwner;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=AddressRepository::class)
*/
class Address extends BaseEntity
{
/**
* @ORM\Column(type="string", length=255)
*/
private $city;
/**
* @ORM\Column(type="string", length=255)
*/
private $country;
/**
* @ORM\Column(type="string", length=255)
*/
private $line1;
/**
* @ORM\Column(type="string", length=255 , nullable="true")
*/
private $line2;
/**
* @ORM\Column(type="string", length=255)
*/
private $postal_code;
/**
* @ORM\Column(type="string", length=255)
*/
private $state;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="addresses")
* @ORM\JoinColumn(nullable=false)
* @IsValidOwner()
*/
protected ?User $owner;
/**
* @ORM\Column(type="address_type")
*/
private $type;
public function __construct()
{
$this->type = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getLine1(): ?string
{
return $this->line1;
}
public function setLine1(string $line1): self
{
$this->line1 = $line1;
return $this;
}
public function getLine2(): ?string
{
return $this->line2;
}
public function setLine2(?string $line2): self
{
$this->line2 = $line2;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postal_code;
}
public function setPostalCode(string $postal_code): self
{
$this->postal_code = $postal_code;
return $this;
}
public function getState(): ?string
{
return $this->state;
}
public function setState(string $state): self
{
$this->state = $state;
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
public function getType()
{
return $this->type;
}
public function setType($type): self
{
$this->type = $type;
return $this;
}
}