Updated to readonly public props on as many models as possible

This commit is contained in:
Alejandro Celaya
2022-04-23 14:00:47 +02:00
parent e79391907a
commit bca3e62ced
74 changed files with 249 additions and 494 deletions

View File

@@ -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];

View File

@@ -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;
}
}

View File

@@ -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));
}

View File

@@ -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);

View File

@@ -37,7 +37,7 @@ class NotifyVisitToRabbitMq
return;
}
$visitId = $shortUrlLocated->visitId();
$visitId = $shortUrlLocated->visitId;
$visit = $this->em->find(Visit::class, $visitId);
if ($visit === null) {

View File

@@ -40,7 +40,7 @@ class NotifyVisitToWebHooks
return;
}
$visitId = $shortUrlLocated->visitId();
$visitId = $shortUrlLocated->visitId;
/** @var Visit|null $visit */
$visit = $this->em->find(Visit::class, $visitId);