<?php
namespace App\Entity\Sms;
use App\Annotation\SiteAware;
use App\Doctrine\Generator\PreparedSMSComunicationIdGenerator;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\MiniAbstractBase;
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\SiteTrait;
use App\Repository\Sms\PreparedSMSCommunicationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="vulco_prepared_sms_comunication")
*
* @ORM\Entity(repositoryClass=PreparedSMSCommunicationRepository::class)
*
* @SiteAware(siteFieldName="site")
*/
class PreparedSMSCommunication implements SiteInterface
{
use CreatedAtTrait;
use SiteTrait;
/**
* @ORM\Id
*
* @ORM\Column(type="prepared_sms_comunication_id", length=255, nullable=false)
*
* @ORM\GeneratedValue(strategy="CUSTOM")
*
* @ORM\CustomIdGenerator(class=PreparedSMSComunicationIdGenerator::class)
*/
private string $id;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private int $amount;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $deliveredTo;
/**
* @ORM\Column(type="text", length=10000, nullable=false)
*/
private string $content;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Sms\SMSComunicationRow", mappedBy="communication", cascade={"persist", "remove"})
*/
private ?Collection $rows;
public function __construct()
{
$this->rows = new ArrayCollection();
}
public function getId(): string
{
return $this->id;
}
public function getAmount(): int
{
return $this->amount;
}
public function setAmount(int $amount): self
{
$this->amount = $amount;
return $this;
}
public function getDeliveredTo(): string
{
return $this->deliveredTo;
}
public function setDeliveredTo(string $deliveredTo): self
{
$this->deliveredTo = $deliveredTo;
return $this;
}
public function getContent(): string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getRows(): ?Collection
{
return $this->rows;
}
public function getRowsAmount(): int
{
return count($this->getRows());
}
public function setRows(?Collection $rows): self
{
$this->rows = $rows;
return $this;
}
public function addRow(SMSComunicationRow $row): self
{
if (!$this->rows->contains($row)) {
$this->rows->add($row);
$row->setCommunication($this);
}
return $this;
}
public function removeRow(SMSComunicationRow $row): self
{
if ($this->rows->contains($row)) {
$this->rows->removeElement($row);
}
return $this;
}
public function __toString(): string
{
return $this->id ? $this->getId() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
}
}