Replaced references to obfuscate by anonymize

This commit is contained in:
Alejandro Celaya
2020-05-08 15:43:09 +02:00
parent bfdd6e0c50
commit 8f06e4b20f
10 changed files with 26 additions and 46 deletions

View File

@@ -21,19 +21,19 @@ class Visit extends AbstractEntity implements JsonSerializable
private ShortUrl $shortUrl;
private ?VisitLocation $visitLocation = null;
public function __construct(ShortUrl $shortUrl, Visitor $visitor, bool $obfuscate = true, ?Chronos $date = null)
public function __construct(ShortUrl $shortUrl, Visitor $visitor, bool $anonymize = true, ?Chronos $date = null)
{
$this->shortUrl = $shortUrl;
$this->date = $date ?? Chronos::now();
$this->userAgent = $visitor->getUserAgent();
$this->referer = $visitor->getReferer();
$this->remoteAddr = $this->processAddress($obfuscate, $visitor->getRemoteAddress());
$this->remoteAddr = $this->processAddress($anonymize, $visitor->getRemoteAddress());
}
private function processAddress(bool $obfuscate, ?string $address): ?string
private function processAddress(bool $anonymize, ?string $address): ?string
{
// Localhost addresses do not need to be obfuscated
if (! $obfuscate || $address === null || $address === IpAddress::LOCALHOST) {
// Localhost addresses do not need to be anonymized
if (! $anonymize || $address === null || $address === IpAddress::LOCALHOST) {
return $address;
}