<?php
namespace App\Entity\System;
use App\Repository\IpAddressCommentBanRepository;
use Carbon\CarbonImmutable;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
#[ORM\Table(name: 'ip_address_comment_ban')]
#[Index(name: 'idx_ip_date', columns: ['ip_address_id', 'date'])]
#[ORM\Entity(repositoryClass: IpAddressCommentBanRepository::class)]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'type', type: 'string', length: 12)]
#[ORM\DiscriminatorMap(['daily' => IpAddressDailyCommentBan::class, 'permanent' => IpAddressPermanentCommentBan::class])]
abstract class IpAddressCommentBan
{
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;
#[ORM\JoinColumn(name: 'ip_address_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: IpAddress::class, inversedBy: 'commentBans')]
protected IpAddress $ipAddress;
#[ORM\Column(name: 'date', type: 'datetimetz_immutable')]
protected \DateTimeImmutable $date;
#[ORM\Column(name: 'is_reset', type: 'boolean', options: ['default' => 0])]
protected bool $isReset;
public function __construct(IpAddress $ip, \DateTimeImmutable $date)
{
$this->ipAddress = $ip;
$this->date = $date;
$this->isReset = false;
}
public function getId(): int
{
return $this->id;
}
public function getIpAddress(): IpAddress
{
return $this->ipAddress;
}
public function getDate(): \DateTimeImmutable
{
return $this->date;
}
public function isReset(): bool
{
return $this->isReset;
}
public function reset(): void
{
$this->isReset = true;
}
abstract public function getType(): string;
}