<?php
namespace App\Entity\Vs;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'vstyp')]
class VsTyp implements \Stringable
{
public const int TYP_EINZEL_VS = 1; // ID aus DB
public const int TYP_DAUER_VS = 2; // ID aus DB
public const int TYP_OHNE_FIXDATUM_VS = 3; // ID aus DB
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
#[ORM\Column(name: 'typname', type: 'string', length: 200, unique: false, nullable: true)]
private ?string $typname = null;
#[ORM\OneToMany(mappedBy: 'typ', targetEntity: Vs::class)]
private Collection $vss;
public function __construct()
{
$this->vss = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setId(?int $id): VsTyp
{
$this->id = $id;
return $this;
}
public function getTypname(): ?string
{
return $this->typname;
}
public function setTypname(?string $typname): VsTyp
{
$this->typname = $typname;
return $this;
}
public function getTypenameShort(): string
{
return strtoupper(substr($this->getTypname(), 0, 1));
}
public function addVss(Vs $vss): static
{
$this->vss[] = $vss;
return $this;
}
public function removeVss(Vs $vss): void
{
$this->vss->removeElement($vss);
}
public function getVss(): ArrayCollection|Collection
{
return $this->vss;
}
// Helpers
public function isEinzelveranstaltung(): bool
{
return $this->id === self::TYP_EINZEL_VS;
}
public function isDauerveranstaltung(): bool
{
return $this->id === self::TYP_DAUER_VS;
}
public function isOhneFixdatum(): bool
{
return $this->id === self::TYP_OHNE_FIXDATUM_VS;
}
#[\Override]
public function __toString(): string
{
return $this->getTypname();
}
}