<?php
namespace App\Entity;
use App\Repository\KpiRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=KpiRepository::class)
*/
class Kpi
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("main")
*/
private $id;
/**
* @ORM\Column(type="string", length=32)
* @Groups("main")
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups("main")
*/
private $description;
/**
* @ORM\Column(type="integer")
* @Groups("main")
*/
private $position;
/**
* @ORM\OneToMany(targetEntity=ExerciseSimpleAnswer::class, mappedBy="kpi")
* @Groups("main")
*/
private $exerciseSimpleAnswers;
/**
* @ORM\OneToMany(targetEntity=ExerciseSorting::class, mappedBy="kpi")
* @Groups("main")
*/
private $exerciseSortings;
/**
* @ORM\OneToMany(targetEntity=ExerciseResult::class, mappedBy="kpi")
* @Groups("main")
*/
private $exerciseResults;
public function __construct()
{
$this->exerciseSimpleAnswers = new ArrayCollection();
if(is_null($this->getPosition())){
$this->setPosition(0);
}
$this->exerciseSortings = new ArrayCollection();
$this->exerciseResults = 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;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
/**
* @return Collection|ExerciseSimpleAnswer[]
*/
public function getExerciseSimpleAnswers(): Collection
{
return $this->exerciseSimpleAnswers;
}
public function addExerciseSimpleAnswer(ExerciseSimpleAnswer $exerciseSimpleAnswer): self
{
if (!$this->exerciseSimpleAnswers->contains($exerciseSimpleAnswer)) {
$this->exerciseSimpleAnswers[] = $exerciseSimpleAnswer;
$exerciseSimpleAnswer->setKpi($this);
}
return $this;
}
public function removeExerciseSimpleAnswer(ExerciseSimpleAnswer $exerciseSimpleAnswer): self
{
if ($this->exerciseSimpleAnswers->removeElement($exerciseSimpleAnswer)) {
// set the owning side to null (unless already changed)
if ($exerciseSimpleAnswer->getKpi() === $this) {
$exerciseSimpleAnswer->setKpi(null);
}
}
return $this;
}
public function __toString()
{
return $this->getName();
}
/**
* @return Collection|ExerciseSorting[]
*/
public function getExerciseSortings(): Collection
{
return $this->exerciseSortings;
}
public function addExerciseSorting(ExerciseSorting $exerciseSorting): self
{
if (!$this->exerciseSortings->contains($exerciseSorting)) {
$this->exerciseSortings[] = $exerciseSorting;
$exerciseSorting->setKpi($this);
}
return $this;
}
public function removeExerciseSorting(ExerciseSorting $exerciseSorting): self
{
if ($this->exerciseSortings->removeElement($exerciseSorting)) {
// set the owning side to null (unless already changed)
if ($exerciseSorting->getKpi() === $this) {
$exerciseSorting->setKpi(null);
}
}
return $this;
}
/**
* @return Collection|ExerciseResult[]
*/
public function getExerciseResults(): Collection
{
return $this->exerciseResults;
}
public function addExerciseResult(ExerciseResult $exerciseResult): self
{
if (!$this->exerciseResults->contains($exerciseResult)) {
$this->exerciseResults[] = $exerciseResult;
$exerciseResult->setKpi($this);
}
return $this;
}
public function removeExerciseResult(ExerciseResult $exerciseResult): self
{
if ($this->exerciseResults->removeElement($exerciseResult)) {
// set the owning side to null (unless already changed)
if ($exerciseResult->getKpi() === $this) {
$exerciseResult->setKpi(null);
}
}
return $this;
}
}