<?phpnamespace App\Entity;use App\Enum\Cursor\Status;use App\Repository\CursorRepository;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=CursorRepository::class) * @ORM\Table(name="`cursor`") */class Cursor{ const DEFAULT_FROM_ID = 1; const DEFAULT_BATCH_SIZE = 100; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\Column(type="integer", nullable=true) */ private $fromId = self::DEFAULT_FROM_ID; /** * @ORM\Column(type="integer", nullable=true) */ private $batchSize = self::DEFAULT_BATCH_SIZE; /** * @ORM\Column(type="string", length=1000, nullable=true) */ private $batchHash; /** * @ORM\Column(type="integer", nullable=true) */ private $toId; /** * @ORM\Column(type="enum", options={"values"="cursor_enum"}) */ private $status = Status::STATUS_ACTIVE; /** * @ORM\OneToOne(targetEntity=Device::class, mappedBy="syncCursor", cascade={"persist", "remove"}) */ private $device; 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 getFromId(): ?int { return $this->fromId; } public function setFromId(?int $fromId): self { $this->fromId = $fromId; return $this; } public function getBatchSize(): ?int { return $this->batchSize; } public function setBatchSize(?int $batchSize): self { if ($batchSize < 1) { $batchSize = self::DEFAULT_BATCH_SIZE; } $this->batchSize = $batchSize; return $this; } public function getBatchHash(): ?string { return $this->batchHash; } public function setBatchHash(?string $batchHash): self { $this->batchHash = $batchHash; return $this; } public function getToId(): ?int { return $this->toId; } public function setToId(?int $toId): self { $this->toId = $toId; return $this; } public function getStatus() { return $this->status; } public function setStatus($status): self { $this->status = $status; return $this; } public function getDevice(): ?Device { return $this->device; } public function setDevice(?Device $device): self { // unset the owning side of the relation if necessary if ($device === null && $this->device !== null) { $this->device->setSyncCursor(null); } // set the owning side of the relation if necessary if ($device !== null && $device->getCursor() !== $this) { $device->setCursor($this); } $this->device = $device; return $this; }}