<?php
namespace App\Entity;
use App\Repository\StatusRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: StatusRepository::class)]
class Status
{
public function __construct(
#[ORM\Id]
#[ORM\Column(type:"string", length:36)]
private ?string $id = null,
#[ORM\Column(type:"string")]
private ?string $name = null,
#[ORM\Column(type:"string")]
private ?string $colour = null,
#[ORM\Column(type:"boolean", options: ['default' => false])]
private bool $isDefault = false,
#[ORM\Column(type:"boolean", options: ['default' => false])]
private bool $isClose = false,
#[ORM\OneToMany(mappedBy: 'status', targetEntity: Ticket::class)]
private ?Collection $tickets = null,
) {
$this->id = $this->id ?? Uuid::v4()->toRfc4122();
$this->tickets = $this->tickets ?? new ArrayCollection();
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getColour(): ?string
{
return $this->colour;
}
/**
* @param string|null $colour
*/
public function setColour(?string $colour): void
{
$this->colour = $colour;
}
/**
* @return bool
*/
public function getIsDefault(): bool
{
return $this->isDefault;
}
/**
* @param bool $isDefault
*/
public function setIsDefault(bool $isDefault): void
{
$this->isDefault = $isDefault;
}
/**
* @return bool
*/
public function getIsClose(): bool
{
return $this->isClose;
}
/**
* @param bool $isClose
*/
public function setIsClose(bool $isClose): void
{
$this->isClose = $isClose;
}
/**
* @return Collection<int, Ticket>|null
*/
public function getTickets(): ?Collection
{
return $this->tickets;
}
public function addTicket(Ticket $ticket): self
{
if ($this->tickets && !$this->tickets->contains($ticket)) {
$this->tickets->add($ticket);
$ticket->setStatus($this);
}
return $this;
}
public function removeTicket(Ticket $ticket): self
{
if ($this->tickets && $this->tickets->contains($ticket)) {
// set the owning side to null (unless already changed)
$this->tickets->removeElement($ticket);
if ($ticket->getStatus() === $this) {
$ticket->setStatus(null);
}
}
return $this;
}
}