Broadcastable event shouldnt be a JsonSerializable everytime

This commit is contained in:
2026-02-27 00:43:06 +04:00
parent b81223a550
commit c481c961fb
2 changed files with 5 additions and 7 deletions

View File

@@ -4,9 +4,7 @@ declare(strict_types=1);
namespace Diffhead\PHP\LaravelRabbitMQ\Event;
use JsonSerializable;
interface Broadcast extends JsonSerializable
interface Broadcast
{
public function getConnection(): string;
public function getQueue(): string;

View File

@@ -11,16 +11,16 @@ use PhpAmqpLib\Message\AMQPMessage;
class Serializer implements SerializerInterface
{
public function serialize(object $data): AMQPMessage
public function serialize(object $event): AMQPMessage
{
if ($data instanceof JsonSerializable) {
if ($event instanceof JsonSerializable) {
return new AMQPMessage(
json_encode($data->jsonSerialize())
json_encode($event->jsonSerialize())
);
}
throw new InvalidArgumentException(
'Data should be an instance of BroadcastEvent'
'Event should be an instance of JsonSerializable'
);
}
}