src/Entity/Card.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Model\Wallet\WalletInterface;
  4. use App\Repository\CardRepository;
  5. use App\Trait\ActivableTrait;
  6. use App\Trait\ArrayableTrait;
  7. use App\Trait\AuthorTrait;
  8. use App\Trait\DateTrait;
  9. use App\Trait\DeletableTrait;
  10. use App\Trait\WalletTrait;
  11. use Doctrine\ORM\Mapping as ORM;
  12. #[ORM\Entity(repositoryClassCardRepository::class)]
  13. class Card implements WalletInterface
  14. {
  15.     use ArrayableTrait;
  16.     use DateTrait {DateTrait::__construct as private dateConstruct;}
  17.     use AuthorTrait;
  18.     use ActivableTrait;
  19.     use DeletableTrait;
  20.     use WalletTrait;
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     private ?int $id null;
  25.     #[ORM\Column]
  26.     private ?string $cardNumber null;
  27.     #[ORM\Column]
  28.     private ?\DateTimeImmutable $expiryAt null;
  29.     #[ORM\ManyToOne(inversedBy'cards')]
  30.     private ?Client $client null;
  31.     #[ORM\ManyToOne(inversedBy'cards')]
  32.     private ?Employee $employee null;
  33.     #[ORM\ManyToOne]
  34.     #[ORM\JoinColumn(nullablefalse)]
  35.     private ?Establishment $establishment null;
  36.     #[ORM\ManyToOne(inversedBy'cards')]
  37.     private ?Mutuality $mutuality null;
  38.     #[ORM\ManyToOne(inversedBy'cards')]
  39.     #[ORM\JoinColumn(nullablefalse)]
  40.     private ?CardType $cardType null;
  41.     #[ORM\ManyToOne(inversedBy'cards')]
  42.     private ?Lot $lot null;
  43.     #[ORM\Column(nullabletrue)]
  44.     private ?int $lotPage null;
  45.     #[ORM\Column(nullabletrue)]
  46.     private ?\DateTimeImmutable $validatedAt null;
  47.     public function __construct()
  48.     {
  49.         $this->dateConstruct();
  50.         $this->validatedAt = new \DateTimeImmutable();
  51.         $this->cardNumber uniqid();
  52.     }
  53.     public function __toString(): string
  54.     {
  55.         return $this->cardNumber;
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getOwner(): Employee|Client|Mutuality|null
  62.     {
  63.         if ($this->cardType->getType() == CardType::EMPLOYEE)
  64.         return $this->getEmployee();
  65.         elseif ($this->cardType->getType() == CardType::CLIENT)
  66.         return $this->getClient();
  67.         elseif ($this->cardType->getType() == CardType::MEMBER)
  68.         return $this->getMutuality();
  69.         return null;
  70.     }
  71.     public function getCardNumber(): ?string
  72.     {
  73.         return $this->cardNumber;
  74.     }
  75.     public function setCardNumber(string $cardNumber): static
  76.     {
  77.         $this->cardNumber $cardNumber;
  78.         return $this;
  79.     }
  80.     public function getExpiryAt(): ?\DateTimeImmutable
  81.     {
  82.         return $this->expiryAt;
  83.     }
  84.     public function setExpiryAt(\DateTimeImmutable $expiryAt): static
  85.     {
  86.         $this->expiryAt $expiryAt;
  87.         return $this;
  88.     }
  89.     public function getClient(): ?Client
  90.     {
  91.         return $this->client;
  92.     }
  93.     public function setClient(?Client $client): static
  94.     {
  95.         $this->client $client;
  96.         return $this;
  97.     }
  98.     public function getEmployee(): ?Employee
  99.     {
  100.         return $this->employee;
  101.     }
  102.     public function setEmployee(?Employee $employee): static
  103.     {
  104.         $this->employee $employee;
  105.         return $this;
  106.     }
  107.     public function getEstablishment(): ?Establishment
  108.     {
  109.         return $this->establishment;
  110.     }
  111.     public function setEstablishment(?Establishment $establishment): static
  112.     {
  113.         $this->establishment $establishment;
  114.         return $this;
  115.     }
  116.     public function getMutuality(): ?Mutuality
  117.     {
  118.         return $this->mutuality;
  119.     }
  120.     public function setMutuality(?Mutuality $mutuality): static
  121.     {
  122.         $this->mutuality $mutuality;
  123.         return $this;
  124.     }
  125.     public function getCardType(): ?CardType
  126.     {
  127.         return $this->cardType;
  128.     }
  129.     public function setCardType(?CardType $cardType): static
  130.     {
  131.         $this->cardType $cardType;
  132.         return $this;
  133.     }
  134.     public function getRef(): ?string
  135.     {
  136.         return $this->ref;
  137.     }
  138.     public function setRef(string $ref): static
  139.     {
  140.         $this->ref $ref;
  141.         return $this;
  142.     }
  143.     public function getLot(): ?Lot
  144.     {
  145.         return $this->lot;
  146.     }
  147.     public function setLot(?Lot $lot): static
  148.     {
  149.         $this->lot $lot;
  150.         return $this;
  151.     }
  152.     public function getLotPage(): ?int
  153.     {
  154.         return $this->lotPage;
  155.     }
  156.     public function setLotPage(?int $lotPage): static
  157.     {
  158.         $this->lotPage $lotPage;
  159.         return $this;
  160.     }
  161.     public function getValidatedAt(): ?\DateTimeImmutable
  162.     {
  163.         return $this->validatedAt;
  164.     }
  165.     public function setValidatedAt(?\DateTimeImmutable $validatedAt): static
  166.     {
  167.         $this->validatedAt $validatedAt;
  168.         return $this;
  169.     }
  170. }