<?php
namespace App\Entity;
use App\Repository\StatutIncidentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: StatutIncidentRepository::class)]
class StatutIncident implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $name= null;
#[ORM\OneToMany(targetEntity: Incident::class, mappedBy: 'statut')]
private mixed $incidents;
public function __construct()
{
$this->incidents = new ArrayCollection();
}
public function __toString(): string
{
return (string) $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|Incident[]
*/
public function getIncidents(): Collection
{
return $this->incidents;
}
public function addIncident(Incident $incident): self
{
if (!$this->incidents->contains($incident)) {
$this->incidents[] = $incident;
$incident->setStatut($this);
}
return $this;
}
public function removeIncident(Incident $incident): self
{
if ($this->incidents->removeElement($incident)) {
// set the owning side to null (unless already changed)
if ($incident->getStatut() === $this) {
$incident->setStatut(null);
}
}
return $this;
}
}