Issues (17)

src/DoctrineDbalRdbmsEventFactory.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gember\RdbmsEventStoreDoctrineDbal;
6
7
use DateTimeImmutable;
8
use Gember\EventSourcing\EventStore\Rdbms\RdbmsEvent;
9
use JsonException;
10
use DateMalformedStringException;
11
12
/**
13
 * @phpstan-import-type Row from DoctrineDbalRdbmsEventStoreRepository
14
 */
15
final readonly class DoctrineDbalRdbmsEventFactory
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 15 at column 6
Loading history...
16
{
17
    /**
18
     * @param Row $row
19
     *
20
     * @throws JsonException
21
     * @throws DateMalformedStringException
22
     */
23 2
    public function createFromRow(array $row): RdbmsEvent
24
    {
25
        /** @var array<string, mixed> $metadata */
26 2
        $metadata = (array) json_decode($row['metadata'], true, flags: JSON_THROW_ON_ERROR);
27
28 2
        return new RdbmsEvent(
29 2
            $row['eventId'],
30 2
            [],
31 2
            $row['eventName'],
32 2
            $row['payload'],
33 2
            $metadata,
34 2
            new DateTimeImmutable($row['appliedAt']),
35 2
        );
36
    }
37
}
38