<?php
namespace App\Entity;
use App\Repository\SubscriberGroupRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SubscriberGroupRepository::class)
*/
class SubscriberGroup
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=Subscriber::class, mappedBy="subscriberGroup")
*/
private $subscribers;
public function __construct()
{
$this->subscribers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Subscriber>
*/
public function getSubscribers(): Collection
{
return $this->subscribers;
}
public function addSubscriber(Subscriber $subscriber): self
{
if (!$this->subscribers->contains($subscriber)) {
$this->subscribers[] = $subscriber;
$subscriber->setSubscriberGroup($this);
}
return $this;
}
public function removeSubscriber(Subscriber $subscriber): self
{
if ($this->subscribers->removeElement($subscriber)) {
// set the owning side to null (unless already changed)
if ($subscriber->getSubscriberGroup() === $this) {
$subscriber->setSubscriberGroup(null);
}
}
return $this;
}
}