-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMessageFactory.php
36 lines (32 loc) · 1.3 KB
/
MessageFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* This file is part of prooph/common.
* (c) 2014-2022 Alexander Miertsch <kontakt@codeliner.ws>
* (c) 2015-2022 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Prooph\Common\Messaging;
interface MessageFactory
{
/**
* Message data MUST contain at least a "payload" key
* but may also contain "uuid", "message_name", "metadata", and "created_at".
*
* In general the message factory MUST support creating event objects from an array returned by
* the corresponding Prooph\Common\Messaging\MessageConverter
*
* You can use the assertion helper Prooph\Common\Messaging\MessageDataAssertion to assert message data
* before processing it.
*
* If one of the optional keys is not part of the message data the factory should use a default instead:
* For example:
* uuid = Uuid::uuid4()
* message_name = $messageName //First parameter passed to the method
* metadata = []
* created_at = new \DateTimeImmutable('now', new \DateTimeZone('UTC')) //We treat all dates as UTC
*/
public function createMessageFromArray(string $messageName, array $messageData): Message;
}