mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-09 08:43:13 +08:00
Created named constructors for Visit entity and added tracking of the visited URL
This commit is contained in:
@@ -18,12 +18,14 @@ final class Visitor
|
||||
|
||||
private string $userAgent;
|
||||
private string $referer;
|
||||
private string $visitedUrl;
|
||||
private ?string $remoteAddress;
|
||||
|
||||
public function __construct(string $userAgent, string $referer, ?string $remoteAddress)
|
||||
public function __construct(string $userAgent, string $referer, ?string $remoteAddress, string $visitedUrl)
|
||||
{
|
||||
$this->userAgent = $this->cropToLength($userAgent, self::USER_AGENT_MAX_LENGTH);
|
||||
$this->referer = $this->cropToLength($referer, self::REFERER_MAX_LENGTH);
|
||||
$this->visitedUrl = $this->cropToLength($visitedUrl, self::VISITED_URL_MAX_LENGTH);
|
||||
$this->remoteAddress = $this->cropToLength($remoteAddress, self::REMOTE_ADDRESS_MAX_LENGTH);
|
||||
}
|
||||
|
||||
@@ -38,12 +40,13 @@ final class Visitor
|
||||
$request->getHeaderLine('User-Agent'),
|
||||
$request->getHeaderLine('Referer'),
|
||||
$request->getAttribute(IpAddressMiddlewareFactory::REQUEST_ATTR),
|
||||
$request->getUri()->__toString(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function emptyInstance(): self
|
||||
{
|
||||
return new self('', '', null);
|
||||
return new self('', '', null, '');
|
||||
}
|
||||
|
||||
public function getUserAgent(): string
|
||||
@@ -60,4 +63,9 @@ final class Visitor
|
||||
{
|
||||
return $this->remoteAddress;
|
||||
}
|
||||
|
||||
public function getVisitedUrl(): string
|
||||
{
|
||||
return $this->visitedUrl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user