8
8
use PDO ;
9
9
use Symfony \Component \Serializer \NameConverter \CamelCaseToSnakeCaseNameConverter ;
10
10
11
- final class DatabaseStorageFacility implements StorageFacility
11
+ /**
12
+ * Class MysqlStorageFacility
13
+ * @package AnyB1s\Data\Common\EventSourcing\EventStore\Storage
14
+ */
15
+ final class MysqlStorageFacility implements StorageFacility
12
16
{
13
17
/** @var PDO $connection */
14
18
private $ connection ;
@@ -31,6 +35,11 @@ public function __construct(PDO $connection, string $table)
31
35
$ this ->table = $ table ;
32
36
}
33
37
38
+ /**
39
+ * @param string $aggregateType
40
+ * @param string $aggregateId
41
+ * @return array
42
+ */
34
43
public function loadEventsOf (string $ aggregateType , string $ aggregateId ): array
35
44
{
36
45
$ statement = $ this ->connection ->prepare (
@@ -42,13 +51,19 @@ public function loadEventsOf(string $aggregateType, string $aggregateId): array
42
51
return $ statement ->fetchAll (PDO ::FETCH_COLUMN );
43
52
}
44
53
54
+ /**
55
+ * @return array
56
+ */
45
57
public function loadAllEvents (): array
46
58
{
47
59
return $ this ->connection
48
60
->prepare ("SELECT `payload` FROM ` {$ this ->table }` " )
49
61
->fetchAll (PDO ::FETCH_COLUMN );
50
62
}
51
63
64
+ /**
65
+ * @param EventEnvelope $eventEnvelope
66
+ */
52
67
public function append (EventEnvelope $ eventEnvelope ): void
53
68
{
54
69
$ statement = $ this ->connection ->prepare ("INSERT INTO ` {$ this ->table }` VALUES (?, ?) " );
@@ -58,6 +73,9 @@ public function append(EventEnvelope $eventEnvelope): void
58
73
$ statement ->execute ();
59
74
}
60
75
76
+ /**
77
+ *
78
+ */
61
79
public function deleteAll (): void
62
80
{
63
81
$ this ->connection ->query ("DELETE FROM ` {$ this ->table }` " );
0 commit comments