Issues (135)

src/Resolver/UseCase/EventSubscriberDefinition.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gember\EventSourcing\Resolver\UseCase;
6
7
use Gember\EventSourcing\Util\Serialization\Serializable;
8
9
/**
10
 * @phpstan-type EventSubscriberDefinitionPayload array{
11
 *      eventClassName: class-string,
12
 *      methodName: string
13
 * }
14
 *
15
 * @implements Serializable<EventSubscriberDefinitionPayload, EventSubscriberDefinition>
16
 */
17
final readonly class EventSubscriberDefinition implements Serializable
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 17 at column 6
Loading history...
18
{
19
    /**
20
     * @param class-string $eventClassName
21
     */
22 15
    public function __construct(
23
        public string $eventClassName,
24
        public string $methodName,
25 15
    ) {}
26
27 4
    public function toPayload(): array
28
    {
29 4
        return [
30 4
            'eventClassName' => $this->eventClassName,
31 4
            'methodName' => $this->methodName,
32 4
        ];
33
    }
34
35 4
    public static function fromPayload(array $payload): self
36
    {
37 4
        return new self(
38 4
            $payload['eventClassName'],
39 4
            $payload['methodName'],
40 4
        );
41
    }
42
}
43