<?php
namespace JanusHercules\ExternallyIncomingApplications\Domain\Entity;
use App\Utility\DatabaseIdGenerator;
use App\Utility\DateTimeUtility;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use JanusHercules\ExternallyIncomingApplications\Domain\Enum\FunnelId;
#[ORM\Entity]
#[ORM\Table(name: 'externally_incoming_applications')]
class ExternallyIncomingApplication
{
public const SOURCE_PERSPECTIVE = 0;
/**
* @throws Exception
*/
public function __construct(
int $source,
string $content,
?FunnelId $funnelId
) {
$this->source = $source;
$this->setContent($content);
$this->createdAt = DateTimeUtility::createDateTimeCet();
$this->funnelId = $funnelId;
}
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
#[ORM\Column(
type : Types::GUID,
unique: true
)]
private ?string $id = null;
public function getId(): ?string
{
return $this->id;
}
#[ORM\Column(
type : Types::INTEGER,
nullable: false
)]
private int $source;
public function getSource(): int
{
return $this->source;
}
#[ORM\Column(
type : Types::STRING,
nullable: true,
enumType: FunnelId::class
)]
private ?FunnelId $funnelId;
public function getFunnelId(): ?FunnelId
{
return $this->funnelId;
}
#[ORM\Column(
type : Types::DATETIME_MUTABLE,
nullable: false
)]
private DateTime $createdAt;
public function setCreatedAt(DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
#[ORM\Column(
type : Types::TEXT,
length : 32768,
nullable: false
)]
private string $content;
public function setContent(string $content): void
{
$this->content = mb_substr($content, 0, 32768);
}
public function getContent(): string
{
return $this->content;
}
}