Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active June 30, 2019 20:41
Show Gist options
  • Select an option

  • Save trikitrok/76c9082ae1a3add22e0695f92a658cbc to your computer and use it in GitHub Desktop.

Select an option

Save trikitrok/76c9082ae1a3add22e0695f92a658cbc to your computer and use it in GitHub Desktop.
<?php
namespace Trovit\B2B\AdClick\Domain;
class ClickValidation
{
private $botClickDetector;
private $domainLogger;
private $paramsValidator;
public function __construct(
BotClickDetector $botClickDetector,
DomainLogger $domainLogger,
ClickParamsValidator $paramsValidator
)
{
$this->botClickDetector = $botClickDetector;
$this->domainLogger = $domainLogger;
$this->paramsValidator = $paramsValidator;
}
public function isValid(array $click)
{
if (!$this->paramsValidator->isValid($click)) {
return false;
}
$isBotClick = $this->botClickDetector->isBot($click['userIp']);
if ($isBotClick) {
$this->domainLogger->logBotClick($click);
return false;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment