<?php
namespace App\Entity;
use App\Repository\ProgramRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="programme")
* @ORM\Entity(repositoryClass=ProgramRepository::class)
*/
class Program
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=Section::class, mappedBy="program")
*/
private $sections;
public function __construct()
{
$this->sections = 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 __toString() {
$name = ( is_null($this->getName())) ? "" : $this->getName();
return (string) ($name );
}
/**
* @return Collection|Section[]
*/
public function getSections(): Collection
{
return $this->sections;
}
public function addSection(Section $section): self
{
if (!$this->sections->contains($section)) {
$this->sections[] = $section;
$section->setProgram($this);
}
return $this;
}
public function removeSection(Section $section): self
{
if ($this->sections->removeElement($section)) {
// set the owning side to null (unless already changed)
if ($section->getProgram() === $this) {
$section->setProgram(null);
}
}
return $this;
}
}