src/Entity/ErrorLog.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ErrorLogRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Enum\ErrorLog\SendStatus;
  6. /**
  7.  * @ORM\Entity(repositoryClass=ErrorLogRepository::class)
  8.  */
  9. class ErrorLog
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="datetime")
  19.      */
  20.     private $createdAt;
  21.     /**
  22.      * @ORM\Column(type="text", nullable=true)
  23.      */
  24.     private $text;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity=User::class)
  27.      */
  28.     private $user;
  29.     /**
  30.      * @ORM\Column(type="text", nullable=true)
  31.      */
  32.     private $trace;
  33.     /**
  34.      * @ORM\Column(type="enum", nullable=true, options={"values": "error_log_enum"})
  35.      */
  36.     private $sendStatus SendStatus::SEND_STATUS_NOT_SENT;
  37.     public function __construct()
  38.     {
  39.         $this->createdAt = new \DateTime();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getCreatedAt(): ?\DateTimeInterface
  46.     {
  47.         return $this->createdAt;
  48.     }
  49.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  50.     {
  51.         $this->createdAt $createdAt;
  52.         return $this;
  53.     }
  54.     public function getText(bool $cut false): ?string
  55.     {
  56.         if ($cut && $this->text && strlen($this->text) > 100) {
  57.             return substr($this->text0100) . "...";
  58.         }
  59.         return $this->text;
  60.     }
  61.     public function setText(?string $text): self
  62.     {
  63.         $this->text $text;
  64.         return $this;
  65.     }
  66.     public function getUser(): ?User
  67.     {
  68.         return $this->user;
  69.     }
  70.     public function setUser(?User $user): self
  71.     {
  72.         $this->user $user;
  73.         return $this;
  74.     }
  75.     public function getTrace(bool $cut false): ?string
  76.     {
  77.         if ($cut && $this->trace && strlen($this->trace) > 200) {
  78.             return trim(substr($this->trace0200)) . "...";
  79.         }
  80.         return $this->trace;
  81.     }
  82.     public function setTrace(?string $trace): self
  83.     {
  84.         $this->trace $trace;
  85.         return $this;
  86.     }
  87.     public function getSendStatus()
  88.     {
  89.         return $this->sendStatus;
  90.     }
  91.     public function setSendStatus($sendStatus): self
  92.     {
  93.         $this->sendStatus $sendStatus;
  94.         return $this;
  95.     }
  96.     public function isSendStatusNotSent(): bool
  97.     {
  98.         return $this->sendStatus === SendStatus::SEND_STATUS_NOT_SENT;
  99.     }
  100.     public function isSendStatusSent(): bool
  101.     {
  102.         return $this->sendStatus === SendStatus::SEND_STATUS_SENT;
  103.     }
  104.     public function isSendStatusError(): bool
  105.     {
  106.         return $this->sendStatus === SendStatus::SEND_STATUS_ERROR;
  107.     }
  108.     public function getSendStatusText(): ?string
  109.     {
  110.         return SendStatus::getText($this->sendStatus);
  111.     }
  112.     public function getSendStatusCssClass($prefix null): ?string
  113.     {
  114.         return SendStatus::getCssClass($this->sendStatus$prefix);
  115.     }
  116. }