67024b5bfd
Signed-off-by: Sebastian <krupinski01@gmail.com>
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXM\Mail;
|
|
|
|
use InvalidArgumentException;
|
|
use KTXF\Event\Event;
|
|
|
|
final class CompositionSavedEvent extends Event {
|
|
|
|
public function __construct(
|
|
string $tenantId,
|
|
private readonly string $userId,
|
|
private readonly string $compositionId,
|
|
private readonly int $revision,
|
|
) {
|
|
if ($tenantId === '' || $this->userId === '' || $this->compositionId === '') {
|
|
throw new InvalidArgumentException('Composition save events require tenant, user, and composition identifiers');
|
|
}
|
|
if ($this->revision < 0) {
|
|
throw new InvalidArgumentException('Composition save event revision cannot be negative');
|
|
}
|
|
|
|
parent::__construct(
|
|
self::class,
|
|
[
|
|
'userId' => $this->userId,
|
|
'compositionId' => $this->compositionId,
|
|
'revision' => $this->revision,
|
|
],
|
|
$tenantId,
|
|
$this->userId,
|
|
);
|
|
}
|
|
|
|
public function userIdentifier(): string {
|
|
return $this->userId;
|
|
}
|
|
|
|
public function compositionIdentifier(): string {
|
|
return $this->compositionId;
|
|
}
|
|
|
|
public function revision(): int {
|
|
return $this->revision;
|
|
}
|
|
}
|