<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;

#[ORM\Entity]
#[ORM\Table(name: 'app_report')]
#[ORM\Index(columns: ['created_at'], name: 'idx_report_created_at')]
class AppReport
{
    #[ORM\Id]
    #[ORM\Column(type: UuidType::NAME, unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private ?Uuid $id = null;

    /** 'bug' ou 'idea' */
    #[ORM\Column(length: 10)]
    private string $type;

    #[ORM\Column(type: 'text')]
    private string $message;

    /** Hash SHA-256 de l'IP — jamais l'IP brute */
    #[ORM\Column(length: 64, nullable: true)]
    private ?string $fingerprint = null;

    #[ORM\Column]
    private \DateTimeImmutable $createdAt;

    public function __construct()
    {
        $this->createdAt = new \DateTimeImmutable();
    }

    public function getId(): ?Uuid { return $this->id; }
    public function getType(): string { return $this->type; }
    public function setType(string $type): static { $this->type = $type; return $this; }
    public function getMessage(): string { return $this->message; }
    public function setMessage(string $message): static { $this->message = $message; return $this; }
    public function getFingerprint(): ?string { return $this->fingerprint; }
    public function setFingerprint(?string $fingerprint): static { $this->fingerprint = $fingerprint; return $this; }
    public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; }
}
