src/Entity/System/IpAddressCommentBan.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use App\Repository\IpAddressCommentBanRepository;
  4. use Carbon\CarbonImmutable;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\ORM\Mapping\Index;
  7. #[ORM\Table(name: 'ip_address_comment_ban')]
  8. #[Index(name: 'idx_ip_date', columns: ['ip_address_id', 'date'])]
  9. #[ORM\Entity(repositoryClass: IpAddressCommentBanRepository::class)]
  10. #[ORM\InheritanceType('SINGLE_TABLE')]
  11. #[ORM\DiscriminatorColumn(name: 'type', type: 'string', length: 12)]
  12. #[ORM\DiscriminatorMap(['daily' => IpAddressDailyCommentBan::class, 'permanent' => IpAddressPermanentCommentBan::class])]
  13. abstract class IpAddressCommentBan
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\Column(name: 'id', type: 'integer')]
  17.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  18.     protected int $id;
  19.     #[ORM\JoinColumn(name: 'ip_address_id', referencedColumnName: 'id')]
  20.     #[ORM\ManyToOne(targetEntity: IpAddress::class, inversedBy: 'commentBans')]
  21.     protected IpAddress $ipAddress;
  22.     #[ORM\Column(name: 'date', type: 'datetimetz_immutable')]
  23.     protected \DateTimeImmutable $date;
  24.     #[ORM\Column(name: 'is_reset', type: 'boolean', options: ['default' => 0])]
  25.     protected bool $isReset;
  26.     public function __construct(IpAddress $ip, \DateTimeImmutable $date)
  27.     {
  28.         $this->ipAddress = $ip;
  29.         $this->date = $date;
  30.         $this->isReset = false;
  31.     }
  32.     public function getId(): int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getIpAddress(): IpAddress
  37.     {
  38.         return $this->ipAddress;
  39.     }
  40.     public function getDate(): \DateTimeImmutable
  41.     {
  42.         return $this->date;
  43.     }
  44.     public function isReset(): bool
  45.     {
  46.         return $this->isReset;
  47.     }
  48.     
  49.     public function reset(): void
  50.     {
  51.         $this->isReset = true;
  52.     }
  53.     abstract public function getType(): string;
  54. }