<?php
// src/Entity/Visitor.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: 'App\Repository\VisitorRepository')]
#[ORM\Table(name: 'visitor')]
class Visitor
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 255)]
private string $ipAddress;
#[ORM\Column(type: 'string', length: 255)]
private string $url;
#[ORM\Column(type: 'datetime')]
private \DateTimeInterface $visitedAt;
#[ORM\Column(type: 'integer')]
private int $visitDuration = 0; // Dauer des Besuchs in Sekunden
#[ORM\Column(type: 'boolean')]
private bool $isBlocked = false;
#[ORM\Column(type: 'datetime', nullable: true)]
private ?\DateTimeInterface $blockedUntil = null;
#[ORM\Column(type: 'boolean')]
private bool $uniqueVisit = false;
#[ORM\Column(type: 'integer')]
private int $clicks = 0; // Anzahl der Klicks
#[ORM\Column(type: 'integer')]
private int $uniqueClicks = 0; // Anzahl der echten Klicks
public function getId(): ?int
{
return $this->id;
}
public function getIpAddress(): string
{
return $this->ipAddress;
}
public function setIpAddress(string $ipAddress): self
{
$this->ipAddress = $ipAddress;
return $this;
}
public function getUrl(): string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
public function getVisitedAt(): \DateTimeInterface
{
return $this->visitedAt;
}
public function setVisitedAt(\DateTimeInterface $visitedAt): self
{
$this->visitedAt = $visitedAt;
return $this;
}
public function getVisitDuration(): int
{
return $this->visitDuration;
}
public function setVisitDuration(int $visitDuration): self
{
$this->visitDuration = $visitDuration;
return $this;
}
public function getIsBlocked(): bool
{
return $this->isBlocked;
}
public function setIsBlocked(bool $isBlocked): self
{
$this->isBlocked = $isBlocked;
return $this;
}
public function getBlockedUntil(): ?\DateTimeInterface
{
return $this->blockedUntil;
}
public function setBlockedUntil(?\DateTimeInterface $blockedUntil): self
{
$this->blockedUntil = $blockedUntil;
return $this;
}
public function isBlocked(): bool
{
if ($this->blockedUntil && new \DateTime() < $this->blockedUntil) {
return true;
}
return false;
}
public function isUniqueVisit(): bool
{
return $this->uniqueVisit;
}
public function setUniqueVisit(bool $uniqueVisit): self
{
$this->uniqueVisit = $uniqueVisit;
return $this;
}
public function getClicks(): int
{
return $this->clicks;
}
public function setClicks(int $clicks): self
{
$this->clicks = $clicks;
return $this;
}
public function getUniqueClicks(): int
{
return $this->uniqueClicks;
}
public function setUniqueClicks(int $uniqueClicks): self
{
$this->uniqueClicks = $uniqueClicks;
return $this;
}
}