mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-08 08:13:11 +08:00
Updated to readonly public props on as many models as possible
This commit is contained in:
@@ -8,15 +8,10 @@ use JsonSerializable;
|
||||
|
||||
abstract class AbstractVisitEvent implements JsonSerializable
|
||||
{
|
||||
public function __construct(protected string $visitId)
|
||||
public function __construct(public readonly string $visitId)
|
||||
{
|
||||
}
|
||||
|
||||
public function visitId(): string
|
||||
{
|
||||
return $this->visitId;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return ['visitId' => $this->visitId];
|
||||
|
||||
@@ -6,13 +6,8 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\Event;
|
||||
|
||||
final class UrlVisited extends AbstractVisitEvent
|
||||
{
|
||||
public function __construct(string $visitId, private ?string $originalIpAddress = null)
|
||||
public function __construct(string $visitId, public readonly ?string $originalIpAddress = null)
|
||||
{
|
||||
parent::__construct($visitId);
|
||||
}
|
||||
|
||||
public function originalIpAddress(): ?string
|
||||
{
|
||||
return $this->originalIpAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class LocateVisit
|
||||
|
||||
public function __invoke(UrlVisited $shortUrlVisited): void
|
||||
{
|
||||
$visitId = $shortUrlVisited->visitId();
|
||||
$visitId = $shortUrlVisited->visitId;
|
||||
|
||||
/** @var Visit|null $visit */
|
||||
$visit = $this->em->find(Visit::class, $visitId);
|
||||
@@ -41,7 +41,7 @@ class LocateVisit
|
||||
return;
|
||||
}
|
||||
|
||||
$this->locateVisit($visitId, $shortUrlVisited->originalIpAddress(), $visit);
|
||||
$this->locateVisit($visitId, $shortUrlVisited->originalIpAddress, $visit);
|
||||
$this->eventDispatcher->dispatch(new VisitLocated($visitId));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class NotifyVisitToMercure
|
||||
|
||||
public function __invoke(VisitLocated $shortUrlLocated): void
|
||||
{
|
||||
$visitId = $shortUrlLocated->visitId();
|
||||
$visitId = $shortUrlLocated->visitId;
|
||||
|
||||
/** @var Visit|null $visit */
|
||||
$visit = $this->em->find(Visit::class, $visitId);
|
||||
|
||||
@@ -37,7 +37,7 @@ class NotifyVisitToRabbitMq
|
||||
return;
|
||||
}
|
||||
|
||||
$visitId = $shortUrlLocated->visitId();
|
||||
$visitId = $shortUrlLocated->visitId;
|
||||
$visit = $this->em->find(Visit::class, $visitId);
|
||||
|
||||
if ($visit === null) {
|
||||
|
||||
@@ -40,7 +40,7 @@ class NotifyVisitToWebHooks
|
||||
return;
|
||||
}
|
||||
|
||||
$visitId = $shortUrlLocated->visitId();
|
||||
$visitId = $shortUrlLocated->visitId;
|
||||
|
||||
/** @var Visit|null $visit */
|
||||
$visit = $this->em->find(Visit::class, $visitId);
|
||||
|
||||
Reference in New Issue
Block a user