<?php
namespace App\Entity;
use App\Repository\QcmRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: QcmRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Qcm
{
use \App\Traits\EntityDateTimeAbleTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $name = null;
#[ORM\OneToMany(targetEntity: QcmQuestion::class, mappedBy: 'qcm')]
private Collection $qcmQuestions;
#[ORM\OneToMany(targetEntity: ProfileQcm::class, mappedBy: 'qcm')]
private Collection $profileQcms;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $times = null;
#[ORM\ManyToMany(targetEntity: Program::class, mappedBy: 'qcm')]
private Collection $programs;
public function __construct()
{
$this->qcmQuestions = new ArrayCollection();
$this->profileQcms = new ArrayCollection();
$this->programs = new ArrayCollection();
}
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<int, QcmQuestion>
*/
public function getQcmQuestions(): Collection
{
return $this->qcmQuestions;
}
public function addQcmQuestion(QcmQuestion $qcmQuestion): self
{
if (!$this->qcmQuestions->contains($qcmQuestion)) {
$this->qcmQuestions[] = $qcmQuestion;
$qcmQuestion->setQcm($this);
}
return $this;
}
public function removeQcmQuestion(QcmQuestion $qcmQuestion): self
{
if ($this->qcmQuestions->removeElement($qcmQuestion)) {
// set the owning side to null (unless already changed)
if ($qcmQuestion->getQcm() === $this) {
$qcmQuestion->setQcm(null);
}
}
return $this;
}
/**
* @return Collection<int, ProfileQcm>
*/
public function getProfileQcms(): Collection
{
return $this->profileQcms;
}
public function addProfileQcm(ProfileQcm $profileQcm): self
{
if (!$this->profileQcms->contains($profileQcm)) {
$this->profileQcms[] = $profileQcm;
$profileQcm->setQcm($this);
}
return $this;
}
public function removeProfileQcm(ProfileQcm $profileQcm): self
{
if ($this->profileQcms->removeElement($profileQcm)) {
// set the owning side to null (unless already changed)
if ($profileQcm->getQcm() === $this) {
$profileQcm->setQcm(null);
}
}
return $this;
}
public function getTimes(): ?int
{
return $this->times;
}
public function setTimes(?int $times): self
{
$this->times = $times;
return $this;
}
/**
* @return Collection<int, Program>
*/
public function getPrograms(): Collection
{
return $this->programs;
}
public function addProgram(Program $program): self
{
if (!$this->programs->contains($program)) {
$this->programs[] = $program;
$program->addQcm($this);
}
return $this;
}
public function removeProgram(Program $program): self
{
if ($this->programs->removeElement($program)) {
$program->removeQcm($this);
}
return $this;
}
}