<?php
namespace JanusHercules\FeedManagementChangeLog\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\FeedManagementChangeLog\Infrastructure\Enum\FeedManagementChangeLogEntryType;
#[ORM\Entity]
#[ORM\Table(name: 'feed_management_change_log_entries')]
class FeedManagementChangeLogEntry
{
/**
* @throws Exception
*/
public function __construct(
string $creatingUserEmail,
FeedManagementChangeLogEntryType $type,
?string $customerInternalId,
?string $oldValue,
?string $newValue
) {
$this->creatingUserEmail = $creatingUserEmail;
$this->customerInternalId = $customerInternalId;
$this->type = $type;
$this->oldValue = $oldValue;
$this->newValue = $newValue;
$this->createdAt = DateTimeUtility::createDateTimeCet();
}
#[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::STRING,
nullable: false
)]
private string $creatingUserEmail;
public function getCreatingUserEmail(): string
{
return $this->creatingUserEmail;
}
#[ORM\Column(
type : Types::STRING,
nullable: true
)]
private ?string $customerInternalId;
public function getCustomerInternalId(): ?string
{
return $this->customerInternalId;
}
#[ORM\Column(
type : Types::STRING,
nullable: false,
enumType: FeedManagementChangeLogEntryType::class
)]
private FeedManagementChangeLogEntryType $type;
public function getType(): FeedManagementChangeLogEntryType
{
return $this->type;
}
#[ORM\Column(
type : Types::STRING,
nullable: true
)]
private ?string $oldValue;
public function getOldValue(): ?string
{
return $this->oldValue;
}
#[ORM\Column(
type : Types::STRING,
nullable: true
)]
private ?string $newValue;
public function getNewValue(): ?string
{
return $this->newValue;
}
#[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;
}
}