src/Entity/Currency.php line 12

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. #[ORM\Table(name'currency')]
  8. #[ORM\Entity(repositoryClassCurrencyRepository::class)]
  9. class Currency {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue('AUTO')]
  12.     #[ORM\Column(type'integer')]
  13.     private ?int $id null;
  14.     #[ORM\Column(name'name'type'string'length255)]
  15.     private string $name;
  16.     #[ORM\Column(name'iso_name'type'string'length255)]
  17.     private string $isoName;
  18.     #[ORM\Column(name'iso_num'type'string'length255)]
  19.     private string $isoNum;
  20.     #[ORM\Column(name'iso_symbol'type'string'length255)]
  21.     private string $isoSymbol;
  22.     #[ORM\OneToMany(mappedBy'currency'targetEntityCountry::class, cascade: ['remove''persist'])]
  23.     private Collection $countries;
  24.     public function __construct() {
  25.         $this->countries = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int {
  28.         return $this->id;
  29.     }
  30.     public function setName(string $name): self {
  31.         $this->name $name;
  32.         return $this;
  33.     }
  34.     public function getName(): string {
  35.         return $this->name;
  36.     }
  37.     public function getIsoName(): string {
  38.         return $this->isoName;
  39.     }
  40.     public function setIsoName($isoName): self {
  41.         $this->isoName $isoName;
  42.         return $this;
  43.     }
  44.     public function getIsoNum(): string {
  45.         return $this->isoNum;
  46.     }
  47.     public function setIsoNum(string $isoNum): self {
  48.         $this->isoNum $isoNum;
  49.         return $this;
  50.     }
  51.     public function getIsoSymbol(): string {
  52.         return $this->isoSymbol;
  53.     }
  54.     public function setIsoSymbol($isoSymbol): self {
  55.         $this->isoSymbol $isoSymbol;
  56.         return $this;
  57.     }
  58.     public function addCountry(Country $country): self {
  59.         $this->countries->add($country);
  60.         return $this;
  61.     }
  62.     public function removeCountry(Country $country): void {
  63.         $this->countries->removeElement($country);
  64.     }
  65.     public function getCountries(): Collection {
  66.         return $this->countries;
  67.     }
  68.     public function __toString() {
  69.         return sprintf('%s'strtoupper($this->name));
  70.     }
  71.     public static function createFixture(
  72.         string $name,
  73.         string $isoName,
  74.         string $isoNum,
  75.         string $isoSymbol
  76.     ): static {
  77.         return (new static())
  78.             ->setName($name)
  79.             ->setIsoNum($isoNum)
  80.             ->setIsoName($isoName)
  81.             ->setIsoSymbol($isoSymbol);
  82.     }
  83. }