<?php
namespace JanusHercules\ExtendedApplicationQuestionnaire\Domain\Entity;
use App\Utility\DatabaseIdGenerator;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JanusHercules\ExtendedApplicationQuestionnaire\Domain\Enum\ExtendedApplicationQuestionnaireQuestionType;
#[ORM\Entity]
#[ORM\Table(
name: 'extended_application_questions'
)]
class ExtendedApplicationQuestion
{
public function __construct(
int $questionNumber,
string $questionText,
bool $isActive,
bool $isOptional,
ExtendedApplicationQuestionnaireQuestionType $questionType
) {
$this->questionNumber = $questionNumber;
$this->questionText = $questionText;
$this->isActive = $isActive;
$this->isOptional = $isOptional;
$this->questionType = $questionType;
$this->extendedApplicationCustomerQuestionTemplates = new ArrayCollection();
$this->extendedApplicationQuestionAnswers = new ArrayCollection();
$this->extendedApplicationQuestionSelectableAnswers = new ArrayCollection();
}
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
#[ORM\Column(
type: Types::GUID,
unique: true
)]
private ?string $id = null;
public function getId(): ?string
{
return $this->id;
}
#[ORM\Column(
type: Types::INTEGER,
nullable: false
)]
private int $questionNumber;
public function getQuestionNumber(): int
{
return $this->questionNumber;
}
public function setQuestionNumber(int $questionNumber): void
{
$this->questionNumber = $questionNumber;
}
#[ORM\Column(
type: Types::TEXT,
nullable: false
)]
private string $questionText;
public function getQuestionText(): string
{
return $this->questionText;
}
public function setQuestionText(string $questionText): void
{
$this->questionText = $questionText;
}
#[ORM\Column(
type: Types::BOOLEAN,
nullable: false
)]
private bool $isActive;
public function isActive(): bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): void
{
$this->isActive = $isActive;
}
#[ORM\Column(
type: Types::BOOLEAN,
nullable: false
)]
private bool $isOptional;
public function isOptional(): bool
{
return $this->isOptional;
}
public function setIsOptional(bool $isOptional): void
{
$this->isOptional = $isOptional;
}
#[ORM\Column(
type: Types::INTEGER,
nullable: false,
enumType: ExtendedApplicationQuestionnaireQuestionType::class
)]
private ExtendedApplicationQuestionnaireQuestionType $questionType;
public function getQuestionType(): ExtendedApplicationQuestionnaireQuestionType
{
return $this->questionType;
}
public function setQuestionType(ExtendedApplicationQuestionnaireQuestionType $questionType): void
{
$this->questionType = $questionType;
}
/**
* @var Collection<int, ExtendedApplicationCustomerQuestionTemplate> $extendedApplicationCustomerQuestionTemplates
*/
#[ORM\OneToMany(
mappedBy: 'extendedApplicationQuestion',
targetEntity: ExtendedApplicationCustomerQuestionTemplate::class,
cascade: ['persist']
)]
private Collection $extendedApplicationCustomerQuestionTemplates;
/**
* @return Collection<int, ExtendedApplicationCustomerQuestionTemplate>
*/
public function getExtendedApplicationCustomerQuestionTemplates(): Collection
{
return $this->extendedApplicationCustomerQuestionTemplates;
}
public function addExtendedApplicationCustomerQuestionTemplate(ExtendedApplicationCustomerQuestionTemplate $questionTemplate): void
{
$this->extendedApplicationCustomerQuestionTemplates->add($questionTemplate);
}
/**
* @var Collection<int, ExtendedApplicationQuestionAnswer> $extendedApplicationQuestionAnswers
*/
#[ORM\OneToMany(
mappedBy: 'extendedApplicationQuestion',
targetEntity: ExtendedApplicationQuestionAnswer::class,
cascade: ['persist']
)]
private Collection $extendedApplicationQuestionAnswers;
/**
* @return Collection<int, ExtendedApplicationQuestionAnswer>
*/
public function getExtendedApplicationQuestionAnswers(): Collection
{
return $this->extendedApplicationQuestionAnswers;
}
/**
* @var Collection<int, ExtendedApplicationQuestionSelectableAnswer> $extendedApplicationQuestionSelectableAnswers
*/
#[ORM\OneToMany(
mappedBy: 'extendedApplicationQuestion',
targetEntity: ExtendedApplicationQuestionSelectableAnswer::class,
cascade: ['persist', 'remove']
)]
private Collection $extendedApplicationQuestionSelectableAnswers;
/**
* @return Collection<int, ExtendedApplicationQuestionSelectableAnswer>
*/
public function getExtendedApplicationQuestionSelectableAnswers(): Collection
{
return $this->extendedApplicationQuestionSelectableAnswers;
}
/** @param Collection<int, ExtendedApplicationQuestionSelectableAnswer> $selectableAnswers */
public function setExtendedApplicationQuestionSelectableAnswers(Collection $selectableAnswers): void
{
$this->extendedApplicationQuestionSelectableAnswers = $selectableAnswers;
}
public function addExtendedApplicationQuestionSelectableAnswer(ExtendedApplicationQuestionSelectableAnswer $selectableAnswer): void
{
$this->extendedApplicationQuestionSelectableAnswers->add($selectableAnswer);
}
public function removeExtendedApplicationQuestionSelectableAnswer(ExtendedApplicationQuestionSelectableAnswer $selectableAnswer): void
{
$this->extendedApplicationQuestionSelectableAnswers->removeElement($selectableAnswer);
}
}