subscriberCookie = $subscriberCookie; $this->subscribersRepository = $subscribersRepository; $this->trackingConfig = $trackingConfig; $this->wp = $wp; } public function identifyByLogin(string $login): void { if (!$this->trackingConfig->isCookieTrackingEnabled()) { return; } $wpUser = $this->wp->getUserBy('login', $login); if ($wpUser) { $this->identifyByEmail($wpUser->user_email); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps } } public function identifyByEmail(string $email): void { if (!$this->trackingConfig->isCookieTrackingEnabled()) { return; } $subscriber = $this->subscribersRepository->findOneBy(['email' => $email]); if ($subscriber) { $this->setCookieBySubscriber($subscriber); } } private function setCookieBySubscriber(SubscriberEntity $subscriber): void { $subscriberId = $subscriber->getId(); if ($subscriberId) { $this->subscriberCookie->setSubscriberId($subscriberId); } } }