src/Entity/Currency.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CurrencyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\UX\Turbo\Attribute\Broadcast;
  8. #[ORM\Entity(repositoryClassCurrencyRepository::class)]
  9. #[Broadcast]
  10. class Currency
  11. {
  12.     use IdentifiableTrait;
  13.     #[ORM\Column(length15)]
  14.     private ?string $name null;
  15.     #[ORM\Column(length10)]
  16.     private ?string $symbol null;
  17.     #[ORM\OneToMany(mappedBy'currency'targetEntityCurrencyRate::class)]
  18.     private Collection $currencyRates;
  19.     #[ORM\OneToMany(mappedBy'currency'targetEntityInvoice::class)]
  20.     private Collection $invoices;
  21.     #[ORM\OneToMany(mappedBy'currency'targetEntityPrescriberPoint::class)]
  22.     private Collection $prescriberPoints;
  23.     #[ORM\Column(length5nullabletrue)]
  24.     private ?string $isoCode null;
  25.     public function __construct()
  26.     {
  27.         $this->currencyRates    = new ArrayCollection();
  28.         $this->invoices         = new ArrayCollection();
  29.         $this->prescriberPoints = new ArrayCollection();
  30.     }
  31.     public function __toString(): string
  32.     {
  33.         return $this->getName()." (".$this->getSymbol().")";
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getName(): ?string
  40.     {
  41.         return $this->name;
  42.     }
  43.     public function setName(string $name): self
  44.     {
  45.         $this->name $name;
  46.         return $this;
  47.     }
  48.     public function getSymbol(): ?string
  49.     {
  50.         return $this->symbol;
  51.     }
  52.     public function setSymbol(string $symbol): self
  53.     {
  54.         $this->symbol $symbol;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection<int, CurrencyRate>
  59.      */
  60.     public function getCurrencyRates(): Collection
  61.     {
  62.         return $this->currencyRates;
  63.     }
  64.     public function addCurrencyRate(CurrencyRate $currencyRate): self
  65.     {
  66.         if (!$this->currencyRates->contains($currencyRate)) {
  67.             $this->currencyRates->add($currencyRate);
  68.             $currencyRate->setCurrency($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeCurrencyRate(CurrencyRate $currencyRate): self
  73.     {
  74.         if ($this->currencyRates->removeElement($currencyRate)) {
  75.             // set the owning side to null (unless already changed)
  76.             if ($currencyRate->getCurrency() === $this) {
  77.                 $currencyRate->setCurrency(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, Invoice>
  84.      */
  85.     public function getInvoices(): Collection
  86.     {
  87.         return $this->invoices;
  88.     }
  89.     public function addInvoice(Invoice $invoice): self
  90.     {
  91.         if (!$this->invoices->contains($invoice)) {
  92.             $this->invoices->add($invoice);
  93.             $invoice->setCurrency($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeInvoice(Invoice $invoice): self
  98.     {
  99.         if ($this->invoices->removeElement($invoice)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($invoice->getCurrency() === $this) {
  102.                 $invoice->setCurrency(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, PrescriberPoint>
  109.      */
  110.     public function getPrescriberPoints(): Collection
  111.     {
  112.         return $this->prescriberPoints;
  113.     }
  114.     public function addPrescriberPoint(PrescriberPoint $prescriberPoint): self
  115.     {
  116.         if (!$this->prescriberPoints->contains($prescriberPoint)) {
  117.             $this->prescriberPoints->add($prescriberPoint);
  118.             $prescriberPoint->setCurrency($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removePrescriberPoint(PrescriberPoint $prescriberPoint): self
  123.     {
  124.         if ($this->prescriberPoints->removeElement($prescriberPoint)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($prescriberPoint->getCurrency() === $this) {
  127.                 $prescriberPoint->setCurrency(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     public function getIsoCode(): ?string
  133.     {
  134.         return $this->isoCode;
  135.     }
  136.     public function setIsoCode(?string $isoCode): static
  137.     {
  138.         $this->isoCode $isoCode;
  139.         return $this;
  140.     }
  141. }