<?php
namespace App\Entity;
use App\Entity\Traits\Timestampable;
use App\Repository\SubSequenceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: SubSequenceRepository::class)]
class SubSequence
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['note'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['note'])]
private ?string $name = null;
#[ORM\Column]
#[Groups(['note'])]
private ?float $percentage = null;
#[ORM\OneToMany(mappedBy: 'subSequence', targetEntity: Note::class)]
private Collection $notes;
#[ORM\ManyToOne(inversedBy: 'subSequences')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['note'])]
private ?Exams $exam = null;
#[ORM\ManyToOne(inversedBy: 'subSequences')]
#[ORM\JoinColumn(nullable: false)]
private ?User $author = null;
#[ORM\ManyToOne(inversedBy: 'subSequences')]
#[ORM\JoinColumn(nullable: false)]
private ?TheClass $classe = null;
#[ORM\ManyToOne(inversedBy: 'subSequences')]
#[ORM\JoinColumn(nullable: false)]
private ?School $School = null;
public function __construct()
{
$this->notes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getPercentage(): ?float
{
return $this->percentage;
}
public function setPercentage(float $percentage): static
{
$this->percentage = $percentage;
return $this;
}
/**
* @return Collection<int, Note>
*/
public function getNotes(): Collection
{
return $this->notes;
}
public function addNote(Note $note): static
{
if (!$this->notes->contains($note)) {
$this->notes->add($note);
$note->setSubSequence($this);
}
return $this;
}
public function removeNote(Note $note): static
{
if ($this->notes->removeElement($note)) {
// set the owning side to null (unless already changed)
if ($note->getSubSequence() === $this) {
$note->setSubSequence(null);
}
}
return $this;
}
public function getExam(): ?Exams
{
return $this->exam;
}
public function setExam(?Exams $exam): static
{
$this->exam = $exam;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
public function getClasse(): ?TheClass
{
return $this->classe;
}
public function setClasse(?TheClass $classe): static
{
$this->classe = $classe;
return $this;
}
public function getSchool(): ?School
{
return $this->School;
}
public function setSchool(?School $School): static
{
$this->School = $School;
return $this;
}
}