for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Event Sourcing implementation
*
* @author Maksim Masiukevich <[email protected]>
* @license MIT
* @license https://opensource.org/licenses/MIT
*/
declare(strict_types = 1);
namespace ServiceBus\EventSourcing\EventStream\Serializer;
use ServiceBus\EventSourcing\EventStream\Serializer\Exceptions\SerializeEventFailed;
use ServiceBus\MessageSerializer\Symfony\SymfonyMessageSerializer;
final class DefaultEventSerializer implements EventSerializer
{
* @var SymfonyMessageSerializer
private $serializer;
public function __construct()
$this->serializer = new SymfonyMessageSerializer();
}
* @inheritDoc
public function serialize(object $event): string
try
return $this->serializer->encode($event);
catch(\Throwable $throwable)
throw SerializeEventFailed::fromThrowable($throwable);
public function unserialize(string $eventClass, string $payload): object
return $this->serializer->decode($payload);