<?php
namespace App\Entity\Common;
use App\Validator\Constraints\LicenseEmbeddableConstraint;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Embeddable]
#[LicenseEmbeddableConstraint]
class LicenseEmbeddable
{
#[ORM\Column(type: 'integer', nullable: false)]
#[
Assert\NotBlank(),
Assert\GreaterThanOrEqual(value: 0)
]
private ?int $countLicenses = null;
#[ORM\Column(type: 'integer', nullable: false)]
#[
Assert\NotBlank(),
Assert\GreaterThanOrEqual(value: 0)
]
private int $countLicensesGiven = 0;
#[ORM\Column(type: 'integer', nullable: false)]
#[
Assert\NotBlank(),
Assert\GreaterThanOrEqual(value: 0)
]
private ?int $unitPrice = null;
public function getTotalLicenses(): ?int
{
return $this->getCountLicenses() + $this->getCountLicensesGiven();
}
public function getTotalAmount(): ?int
{
return $this->getUnitPrice() * $this->getCountLicenses();
}
public function getCountLicenses(): ?int
{
return $this->countLicenses;
}
public function setCountLicenses(?int $countLicenses): static
{
$this->countLicenses = $countLicenses;
return $this;
}
public function getCountLicensesGiven(): int
{
return $this->countLicensesGiven;
}
public function setCountLicensesGiven(int $countLicensesGiven): static
{
$this->countLicensesGiven = $countLicensesGiven;
return $this;
}
public function getUnitPrice(): ?int
{
return $this->unitPrice;
}
public function setUnitPrice(?int $unitPrice): static
{
$this->unitPrice = $unitPrice;
return $this;
}
}