*/ private $clicks; public function __construct( NewsletterEntity $newsletter, SendingQueueEntity $queue, string $url, string $hash ) { $this->newsletter = $newsletter; $this->queue = $queue; $this->url = $url; $this->hash = $hash; } /** * @return NewsletterEntity|null */ public function getNewsletter() { $this->safelyLoadToOneAssociation('newsletter'); return $this->newsletter; } /** * @return SendingQueueEntity|null */ public function getQueue() { $this->safelyLoadToOneAssociation('queue'); return $this->queue; } public function getUrl(): string { return $this->url; } public function getHash(): string { return $this->hash; } /** * @return int */ public function getTotalClicksCount() { return $this->clicks->count(); } public function toArray(): array { return [ 'id' => $this->getId(), 'newsletter_id' => ($this->getNewsletter() instanceof NewsletterEntity) ? $this->getNewsletter()->getId() : null, 'queue_id' => ($this->getQueue() instanceof SendingQueueEntity) ? $this->getQueue()->getId() : null, 'url' => $this->getUrl(), 'hash' => $this->getHash(), 'created_at' => $this->getCreatedAt(), 'updated_at' => $this->getUpdatedAt(), ]; } }