<?php
namespace App\Entity;
use App\Repository\SubscriberRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SubscriberRepository::class)
*/
class Subscriber
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="boolean")
*/
private $isConfirmed = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $confirmationToken;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=SubscriberGroup::class, inversedBy="subscribers")
*/
private $subscriberGroup;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $name;
public function __construct()
{
$this->confirmationToken = $this->strToken(20);
$this->createdAt = new \DateTime('now', new \DateTimeZone('Europe/Paris'));
}
public function StrToken($length)
{
$alpha = "0123456789azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN-_";
return substr(str_shuffle(str_repeat($alpha, $length)), 0, $length);
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function isIsConfirmed(): ?bool
{
return $this->isConfirmed;
}
public function setIsConfirmed(bool $isConfirmed): self
{
$this->isConfirmed = $isConfirmed;
return $this;
}
public function getConfirmationToken(): ?string
{
return $this->confirmationToken;
}
public function setConfirmationToken(?string $confirmationToken): self
{
$this->confirmationToken = $confirmationToken;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getSubscriberGroup(): ?SubscriberGroup
{
return $this->subscriberGroup;
}
public function setSubscriberGroup(?SubscriberGroup $subscriberGroup): self
{
$this->subscriberGroup = $subscriberGroup;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
}