src/Entity/Cursor.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\Cursor\Status;
  4. use App\Repository\CursorRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=CursorRepository::class)
  8.  * @ORM\Table(name="`cursor`")
  9.  */
  10. class Cursor
  11. {
  12.     const DEFAULT_FROM_ID 1;
  13.     const DEFAULT_BATCH_SIZE 100;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="datetime")
  22.      */
  23.     private $createdAt;
  24.     /**
  25.      * @ORM\Column(type="integer", nullable=true)
  26.      */
  27.     private $fromId self::DEFAULT_FROM_ID;
  28.     /**
  29.      * @ORM\Column(type="integer", nullable=true)
  30.      */
  31.     private $batchSize self::DEFAULT_BATCH_SIZE;
  32.     /**
  33.      * @ORM\Column(type="string", length=1000, nullable=true)
  34.      */
  35.     private $batchHash;
  36.     /**
  37.      * @ORM\Column(type="integer", nullable=true)
  38.      */
  39.     private $toId;
  40.     /**
  41.      * @ORM\Column(type="enum", options={"values"="cursor_enum"})
  42.      */
  43.     private $status Status::STATUS_ACTIVE;
  44.     /**
  45.      * @ORM\OneToOne(targetEntity=Device::class, mappedBy="syncCursor", cascade={"persist", "remove"})
  46.      */
  47.     private $device;
  48.     public function __construct()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getCreatedAt(): ?\DateTimeInterface
  57.     {
  58.         return $this->createdAt;
  59.     }
  60.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  61.     {
  62.         $this->createdAt $createdAt;
  63.         return $this;
  64.     }
  65.     public function getFromId(): ?int
  66.     {
  67.         return $this->fromId;
  68.     }
  69.     public function setFromId(?int $fromId): self
  70.     {
  71.         $this->fromId $fromId;
  72.         return $this;
  73.     }
  74.     public function getBatchSize(): ?int
  75.     {
  76.         return $this->batchSize;
  77.     }
  78.     public function setBatchSize(?int $batchSize): self
  79.     {
  80.         if ($batchSize 1) {
  81.             $batchSize self::DEFAULT_BATCH_SIZE;
  82.         }
  83.         $this->batchSize $batchSize;
  84.         return $this;
  85.     }
  86.     public function getBatchHash(): ?string
  87.     {
  88.         return $this->batchHash;
  89.     }
  90.     public function setBatchHash(?string $batchHash): self
  91.     {
  92.         $this->batchHash $batchHash;
  93.         return $this;
  94.     }
  95.     public function getToId(): ?int
  96.     {
  97.         return $this->toId;
  98.     }
  99.     public function setToId(?int $toId): self
  100.     {
  101.         $this->toId $toId;
  102.         return $this;
  103.     }
  104.     public function getStatus()
  105.     {
  106.         return $this->status;
  107.     }
  108.     public function setStatus($status): self
  109.     {
  110.         $this->status $status;
  111.         return $this;
  112.     }
  113.     public function getDevice(): ?Device
  114.     {
  115.         return $this->device;
  116.     }
  117.     public function setDevice(?Device $device): self
  118.     {
  119.         // unset the owning side of the relation if necessary
  120.         if ($device === null && $this->device !== null) {
  121.             $this->device->setSyncCursor(null);
  122.         }
  123.         // set the owning side of the relation if necessary
  124.         if ($device !== null && $device->getCursor() !== $this) {
  125.             $device->setCursor($this);
  126.         }
  127.         $this->device $device;
  128.         return $this;
  129.     }
  130. }