<?phpnamespace App\Entity;use App\Repository\ErrorLogRepository;use Doctrine\ORM\Mapping as ORM;use App\Enum\ErrorLog\SendStatus;/** * @ORM\Entity(repositoryClass=ErrorLogRepository::class) */class ErrorLog{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\Column(type="text", nullable=true) */ private $text; /** * @ORM\ManyToOne(targetEntity=User::class) */ private $user; /** * @ORM\Column(type="text", nullable=true) */ private $trace; /** * @ORM\Column(type="enum", nullable=true, options={"values": "error_log_enum"}) */ private $sendStatus = SendStatus::SEND_STATUS_NOT_SENT; public function __construct() { $this->createdAt = new \DateTime(); } public function getId(): ?int { return $this->id; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getText(bool $cut = false): ?string { if ($cut && $this->text && strlen($this->text) > 100) { return substr($this->text, 0, 100) . "..."; } return $this->text; } public function setText(?string $text): self { $this->text = $text; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } public function getTrace(bool $cut = false): ?string { if ($cut && $this->trace && strlen($this->trace) > 200) { return trim(substr($this->trace, 0, 200)) . "..."; } return $this->trace; } public function setTrace(?string $trace): self { $this->trace = $trace; return $this; } public function getSendStatus() { return $this->sendStatus; } public function setSendStatus($sendStatus): self { $this->sendStatus = $sendStatus; return $this; } public function isSendStatusNotSent(): bool { return $this->sendStatus === SendStatus::SEND_STATUS_NOT_SENT; } public function isSendStatusSent(): bool { return $this->sendStatus === SendStatus::SEND_STATUS_SENT; } public function isSendStatusError(): bool { return $this->sendStatus === SendStatus::SEND_STATUS_ERROR; } public function getSendStatusText(): ?string { return SendStatus::getText($this->sendStatus); } public function getSendStatusCssClass($prefix = null): ?string { return SendStatus::getCssClass($this->sendStatus, $prefix); }}