<?php
namespace App\Entity;
use App\Repository\QuestionnaireRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=QuestionnaireRepository::class)
*/
class Questionnaire
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=Question::class, mappedBy="questionnaire", orphanRemoval=true)
*/
private $questions;
/**
* @ORM\OneToOne(targetEntity=Rank::class, cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $rank =1;
public function __construct()
{
$this->questions = 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, Question>
*/
public function getQuestions(): Collection
{
return $this->questions;
}
public function addQuestion(Question $question): self
{
if (!$this->questions->contains($question)) {
$this->questions[] = $question;
$question->setQuestionnaire($this);
}
return $this;
}
public function removeQuestion(Question $question): self
{
if ($this->questions->removeElement($question)) {
// set the owning side to null (unless already changed)
if ($question->getQuestionnaire() === $this) {
$question->setQuestionnaire(null);
}
}
return $this;
}
public function getRank(): ?Rank
{
return $this->rank;
}
public function setRank(Rank $rank): self
{
$this->rank = $rank;
return $this;
}
}