<?php
namespace App\Entity;
use App\Repository\CountyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CountyRepository::class)
*/
class County
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column
*/
private ?int $id = null;
/**
* @ORM\Column(length=255)
*/
private ?string $name = null;
/**
* @ORM\Column(length=255)
*/
private ?string $ctyCode = null;
/**
* @ORM\OneToMany(mappedBy="county", targetEntity=City::class)
*/
private Collection $cities;
public function __construct()
{
$this->cities = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getCtyCode(): ?string
{
return $this->ctyCode;
}
public function setCtyCode(string $ctyCode): static
{
$this->ctyCode = $ctyCode;
return $this;
}
/**
* @return Collection<int, City>
*/
public function getCities(): Collection
{
return $this->cities;
}
public function addCity(City $city): static
{
if (!$this->cities->contains($city)) {
$this->cities->add($city);
$city->setCounty($this);
}
return $this;
}
public function removeCity(City $city): static
{
if ($this->cities->removeElement($city)) {
// set the owning side to null (unless already changed)
if ($city->getCounty() === $this) {
$city->setCounty(null);
}
}
return $this;
}
}