Broadcastable event shouldnt be a JsonSerializable everytime
This commit is contained in:
@@ -4,9 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Diffhead\PHP\LaravelRabbitMQ\Event;
|
namespace Diffhead\PHP\LaravelRabbitMQ\Event;
|
||||||
|
|
||||||
use JsonSerializable;
|
interface Broadcast
|
||||||
|
|
||||||
interface Broadcast extends JsonSerializable
|
|
||||||
{
|
{
|
||||||
public function getConnection(): string;
|
public function getConnection(): string;
|
||||||
public function getQueue(): string;
|
public function getQueue(): string;
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ use PhpAmqpLib\Message\AMQPMessage;
|
|||||||
|
|
||||||
class Serializer implements SerializerInterface
|
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(
|
return new AMQPMessage(
|
||||||
json_encode($data->jsonSerialize())
|
json_encode($event->jsonSerialize())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
'Data should be an instance of BroadcastEvent'
|
'Event should be an instance of JsonSerializable'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user