src/Entity/CRM/OrderLicence.php line 10

  1. <?php
  2. namespace App\Entity\CRM;
  3. use App\Repository\CRM\OrderLicenceRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassOrderLicenceRepository::class)]
  7. class OrderLicence
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\Column(length255)]
  14.     private ?string $name null;
  15.     #[ORM\Column(length255nullabletrue)]
  16.     private ?string $licenseId null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $orderNumber null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $licenseKey null;
  21.     #[ORM\Column(nullabletrue)]
  22.     private ?bool $isRevoked null;
  23.     #[ORM\Column(nullabletrue)]
  24.     private ?bool $isRegistered null;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $licenseHolderCrmId null;
  27.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  28.     private ?array $modules null;
  29.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  30.     private ?\DateTimeInterface $addedDate null;
  31.     #[ORM\ManyToOne(inversedBy'orderLicense')]
  32.     #[ORM\JoinColumn(nullablefalse)]
  33.     private ?Order $orderInstance null;
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): static
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function getLicenseId(): ?string
  48.     {
  49.         return $this->licenseId;
  50.     }
  51.     public function setLicenseId(?string $licenseId): static
  52.     {
  53.         $this->licenseId $licenseId;
  54.         return $this;
  55.     }
  56.     public function getOrderNumber(): ?string
  57.     {
  58.         return $this->orderNumber;
  59.     }
  60.     public function setOrderNumber(?string $orderNumber): static
  61.     {
  62.         $this->orderNumber $orderNumber;
  63.         return $this;
  64.     }
  65.     public function getLicenseKey(): ?string
  66.     {
  67.         return $this->licenseKey;
  68.     }
  69.     public function setLicenseKey(?string $licenseKey): static
  70.     {
  71.         $this->licenseKey $licenseKey;
  72.         return $this;
  73.     }
  74.     public function isRevoked(): ?bool
  75.     {
  76.         return $this->isRevoked;
  77.     }
  78.     public function setIsRevoked(?bool $isRevoked): static
  79.     {
  80.         $this->isRevoked $isRevoked;
  81.         return $this;
  82.     }
  83.     public function isRegistered(): ?bool
  84.     {
  85.         return $this->isRegistered;
  86.     }
  87.     public function setIsRegistered(?bool $isRegistered): static
  88.     {
  89.         $this->isRegistered $isRegistered;
  90.         return $this;
  91.     }
  92.     public function getLicenseHolderCrmId(): ?string
  93.     {
  94.         return $this->licenseHolderCrmId;
  95.     }
  96.     public function setLicenseHolderCrmId(?string $licenseHolderCrmId): static
  97.     {
  98.         $this->licenseHolderCrmId $licenseHolderCrmId;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return string[]
  103.      */
  104.     public function getModules(): array
  105.     {
  106.         if ($this->modules === null) {
  107.             return [];
  108.         }
  109.         return self::normalizeModules($this->modules);
  110.     }
  111.     /**
  112.      * @param string[]|null $modules
  113.      */
  114.     public function setModules(?array $modules): static
  115.     {
  116.         $this->modules $modules !== null self::normalizeModules($modules) : null;
  117.         return $this;
  118.     }
  119.     public function getModulesLabel(): string
  120.     {
  121.         return implode(', '$this->getModules());
  122.     }
  123.     private static function normalizeModules(array $modules): array
  124.     {
  125.         $normalized = [];
  126.         foreach ($modules as $module) {
  127.             if (!is_scalar($module)) {
  128.                 continue;
  129.             }
  130.             $moduleName trim((string) $module);
  131.             if ($moduleName === '' || in_array($moduleName$normalizedtrue)) {
  132.                 continue;
  133.             }
  134.             $normalized[] = $moduleName;
  135.         }
  136.         return $normalized;
  137.     }
  138.     public function getAddedDate(): ?\DateTimeInterface
  139.     {
  140.         return $this->addedDate;
  141.     }
  142.     public function setAddedDate(\DateTimeInterface $addedDate): static
  143.     {
  144.         $this->addedDate $addedDate;
  145.         return $this;
  146.     }
  147.     public function getOrderInstance(): ?Order
  148.     {
  149.         return $this->orderInstance;
  150.     }
  151.     public function setOrderInstance(?Order $orderInstance): static
  152.     {
  153.         $this->orderInstance $orderInstance;
  154.         return $this;
  155.     }
  156. }