src/Entity/TestMethod.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TestMethodRepository;
  4. use Doctrine\Common\Collections\{ ArrayCollectionCollection };
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. #[ORM\Entity(repositoryClassTestMethodRepository::class), ORM\Table(name'test_methods')]
  8. class TestMethod implements \Stringable
  9. {
  10.     #[ORM\IdORM\GeneratedValueORM\Column(type'integer')]
  11.     private $id;
  12.     #[ORM\Column(type'string'length255)]
  13.     private $name;
  14.     #[ORM\OneToMany(targetEntityLabTestMethod::class, mappedBy'method'orphanRemovaltrue)]
  15.     private $methods;
  16.     #[Gedmo\Blameable(on'create'), ORM\ManyToOne(targetEntityUser::class), ORM\JoinColumn(name'created_by')]
  17.     private $createdBy;
  18.     public function __construct()
  19.     {
  20.         $this->methods = new ArrayCollection();
  21.     }
  22.     public function getId(): ?int
  23.     {
  24.         return $this->id;
  25.     }
  26.     public function getName(): ?string
  27.     {
  28.         return $this->name;
  29.     }
  30.     public function setName(string $name): self
  31.     {
  32.         $this->name $name;
  33.         return $this;
  34.     }
  35.     public function getCreatedBy(): ?User
  36.     {
  37.         return $this->createdBy;
  38.     }
  39.     /**
  40.      * @return Collection|LabTestMethod[]
  41.      */
  42.     public function getMethods(): Collection
  43.     {
  44.         return $this->methods;
  45.     }
  46.     public function __toString(): string
  47.     {
  48.         return $this->getName();
  49.     }
  50.     public function addMethod(LabTestMethod $method): self
  51.     {
  52.         if (!$this->methods->contains($method)) {
  53.             $this->methods[] = $method;
  54.             $method->setMethod($this);
  55.         }
  56.         return $this;
  57.     }
  58.     public function removeMethod(LabTestMethod $method): self
  59.     {
  60.         if ($this->methods->removeElement($method)) {
  61.             if ($method->getMethod() === $this) {
  62.                 $method->setMethod(null);
  63.             }
  64.         }
  65.         return $this;
  66.     }
  67. }