isUnderTimeThreshold($emailStat, $emailHitDateTime) + (int) $this->isIpInIgnoreList($ipAddress) + (int) $this->isUserAgentInIgnoreList($userAgent); return $totalPoints / 3 >= $this->botRatioThreshold; } private function isUnderTimeThreshold(Stat $emailStat, \DateTimeInterface $emailHitDateTime): bool { $timeFromSend = $emailHitDateTime->getTimestamp() - $emailStat->getDateSent()->getTimestamp(); return $timeFromSend < $this->timeFromEmailThreshold; } private function isIpInIgnoreList(IpAddress $ipAddress): bool { // Create a clone so that setting up do not track IP list here will not update original blocked Ip List $ipAddressLocal = clone $ipAddress; $ipAddressLocal->setDoNotTrackList($this->blockedIPAddresses); return !$ipAddressLocal->isTrackable(); } private function isUserAgentInIgnoreList(string $userAgent): bool { foreach ($this->blockedUserAgents as $blockedUserAgent) { if (str_contains($userAgent, $blockedUserAgent)) { return true; } } return false; } }