src/Entity/Card.php line 16
<?phpnamespace App\Entity;use App\Model\Wallet\WalletInterface;use App\Repository\CardRepository;use App\Trait\ActivableTrait;use App\Trait\ArrayableTrait;use App\Trait\AuthorTrait;use App\Trait\DateTrait;use App\Trait\DeletableTrait;use App\Trait\WalletTrait;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CardRepository::class)]class Card implements WalletInterface{use ArrayableTrait;use DateTrait {DateTrait::__construct as private dateConstruct;}use AuthorTrait;use ActivableTrait;use DeletableTrait;use WalletTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column]private ?string $cardNumber = null;#[ORM\Column]private ?\DateTimeImmutable $expiryAt = null;#[ORM\ManyToOne(inversedBy: 'cards')]private ?Client $client = null;#[ORM\ManyToOne(inversedBy: 'cards')]private ?Employee $employee = null;#[ORM\ManyToOne]#[ORM\JoinColumn(nullable: false)]private ?Establishment $establishment = null;#[ORM\ManyToOne(inversedBy: 'cards')]private ?Mutuality $mutuality = null;#[ORM\ManyToOne(inversedBy: 'cards')]#[ORM\JoinColumn(nullable: false)]private ?CardType $cardType = null;#[ORM\ManyToOne(inversedBy: 'cards')]private ?Lot $lot = null;#[ORM\Column(nullable: true)]private ?int $lotPage = null;#[ORM\Column(nullable: true)]private ?\DateTimeImmutable $validatedAt = null;public function __construct(){$this->dateConstruct();$this->validatedAt = new \DateTimeImmutable();$this->cardNumber = uniqid();}public function __toString(): string{return $this->cardNumber;}public function getId(): ?int{return $this->id;}public function getOwner(): Employee|Client|Mutuality|null{if ($this->cardType->getType() == CardType::EMPLOYEE)return $this->getEmployee();elseif ($this->cardType->getType() == CardType::CLIENT)return $this->getClient();elseif ($this->cardType->getType() == CardType::MEMBER)return $this->getMutuality();return null;}public function getCardNumber(): ?string{return $this->cardNumber;}public function setCardNumber(string $cardNumber): static{$this->cardNumber = $cardNumber;return $this;}public function getExpiryAt(): ?\DateTimeImmutable{return $this->expiryAt;}public function setExpiryAt(\DateTimeImmutable $expiryAt): static{$this->expiryAt = $expiryAt;return $this;}public function getClient(): ?Client{return $this->client;}public function setClient(?Client $client): static{$this->client = $client;return $this;}public function getEmployee(): ?Employee{return $this->employee;}public function setEmployee(?Employee $employee): static{$this->employee = $employee;return $this;}public function getEstablishment(): ?Establishment{return $this->establishment;}public function setEstablishment(?Establishment $establishment): static{$this->establishment = $establishment;return $this;}public function getMutuality(): ?Mutuality{return $this->mutuality;}public function setMutuality(?Mutuality $mutuality): static{$this->mutuality = $mutuality;return $this;}public function getCardType(): ?CardType{return $this->cardType;}public function setCardType(?CardType $cardType): static{$this->cardType = $cardType;return $this;}public function getRef(): ?string{return $this->ref;}public function setRef(string $ref): static{$this->ref = $ref;return $this;}public function getLot(): ?Lot{return $this->lot;}public function setLot(?Lot $lot): static{$this->lot = $lot;return $this;}public function getLotPage(): ?int{return $this->lotPage;}public function setLotPage(?int $lotPage): static{$this->lotPage = $lotPage;return $this;}public function getValidatedAt(): ?\DateTimeImmutable{return $this->validatedAt;}public function setValidatedAt(?\DateTimeImmutable $validatedAt): static{$this->validatedAt = $validatedAt;return $this;}}