<?php
namespace App\Entity;
use App\Repository\TestMethodRepository;
use Doctrine\Common\Collections\{ ArrayCollection, Collection };
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: TestMethodRepository::class), ORM\Table(name: 'test_methods')]
class TestMethod implements \Stringable
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\OneToMany(targetEntity: LabTestMethod::class, mappedBy: 'method', orphanRemoval: true)]
private $methods;
#[Gedmo\Blameable(on: 'create'), ORM\ManyToOne(targetEntity: User::class), ORM\JoinColumn(name: 'created_by')]
private $createdBy;
public function __construct()
{
$this->methods = 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 getCreatedBy(): ?User
{
return $this->createdBy;
}
/**
* @return Collection|LabTestMethod[]
*/
public function getMethods(): Collection
{
return $this->methods;
}
public function __toString(): string
{
return $this->getName();
}
public function addMethod(LabTestMethod $method): self
{
if (!$this->methods->contains($method)) {
$this->methods[] = $method;
$method->setMethod($this);
}
return $this;
}
public function removeMethod(LabTestMethod $method): self
{
if ($this->methods->removeElement($method)) {
if ($method->getMethod() === $this) {
$method->setMethod(null);
}
}
return $this;
}
}