src/Entity/Common/LicenseEmbeddable.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Common;
  3. use App\Validator\Constraints\LicenseEmbeddableConstraint;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. #[ORM\Embeddable]
  7. #[LicenseEmbeddableConstraint]
  8. class LicenseEmbeddable
  9. {
  10.     #[ORM\Column(type'integer'nullablefalse)]
  11.     #[
  12.         Assert\NotBlank(),
  13.         Assert\GreaterThanOrEqual(value0)
  14.     ]
  15.     private ?int $countLicenses null;
  16.     #[ORM\Column(type'integer'nullablefalse)]
  17.     #[
  18.         Assert\NotBlank(),
  19.         Assert\GreaterThanOrEqual(value0)
  20.     ]
  21.     private int $countLicensesGiven 0;
  22.     #[ORM\Column(type'integer'nullablefalse)]
  23.     #[
  24.         Assert\NotBlank(),
  25.         Assert\GreaterThanOrEqual(value0)
  26.     ]
  27.     private ?int $unitPrice null;
  28.     public function getTotalLicenses(): ?int
  29.     {
  30.         return $this->getCountLicenses() + $this->getCountLicensesGiven();
  31.     }
  32.     public function getTotalAmount(): ?int
  33.     {
  34.         return $this->getUnitPrice() * $this->getCountLicenses();
  35.     }
  36.     public function getCountLicenses(): ?int
  37.     {
  38.         return $this->countLicenses;
  39.     }
  40.     public function setCountLicenses(?int $countLicenses): static
  41.     {
  42.         $this->countLicenses $countLicenses;
  43.         return $this;
  44.     }
  45.     public function getCountLicensesGiven(): int
  46.     {
  47.         return $this->countLicensesGiven;
  48.     }
  49.     public function setCountLicensesGiven(int $countLicensesGiven): static
  50.     {
  51.         $this->countLicensesGiven $countLicensesGiven;
  52.         return $this;
  53.     }
  54.     public function getUnitPrice(): ?int
  55.     {
  56.         return $this->unitPrice;
  57.     }
  58.     public function setUnitPrice(?int $unitPrice): static
  59.     {
  60.         $this->unitPrice $unitPrice;
  61.         return $this;
  62.     }
  63. }