<?php
namespace App\Entity;
use App\Repository\ScoreRepository;
use Doctrine\ORM\Mapping as ORM;
use Overblog\GraphQLBundle\Annotation\Field;
#[ORM\Entity(repositoryClass: ScoreRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Score extends BasicEntity
{
public const TYPE_LEAKED_PWD = 'LP';
public const TYPE_VULNERABILITY = 'VL';
public const TYPE_PORT = 'PR';
public const TYPE_ATTACK_SURFACE = 'AS';
public const TYPE_DARK_WEB = 'DW';
public const TYPE_GLOBAL_SCORE = 'GS';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Field(name: "id", type: "int")]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Field(name: "type", type: "string")]
private ?string $type = null;
#[ORM\Column]
#[Field(name: "score", type: "float")]
private ?float $score = null;
#[ORM\Column]
#[Field(name: "created_at", type: "date")]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(length: 255)]
#[Field(name: "label", type: "string")]
private ?string $label = null;
#[ORM\ManyToOne(inversedBy: 'scores')]
#[ORM\JoinColumn(nullable: false)]
private ?Domain $domain = null;
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): static
{
$this->type = $type;
return $this;
}
public function getScore(): ?float
{
return $this->score;
}
public function setScore(float $score): static
{
$this->score = $score;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function forceCreateAt(\DateTimeImmutable $date): static
{
$this->createdAt = $date;
return $this;
}
#[ORM\PrePersist]
#[ORM\PreUpdate]
public function setCreatedAt(): static
{
if($this->createdAt === null) {
$this->createdAt = new \DateTimeImmutable();
}
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
public function getDomain(): ?Domain
{
return $this->domain;
}
public function setDomain(?Domain $domain): static
{
$this->domain = $domain;
return $this;
}
}