diff --git a/src/Adapter/AbstractAdapter.php b/src/Adapter/AbstractAdapter.php index a85954e..fc67bb0 100644 --- a/src/Adapter/AbstractAdapter.php +++ b/src/Adapter/AbstractAdapter.php @@ -2,6 +2,37 @@ namespace ReputationVIP\QueueClient\Adapter; +use ReputationVIP\QueueClient\QueueClientInterface; + class AbstractAdapter { + + /** + * @param string $queueName + * @param array $messages + * @param string $priority + * + * @return QueueClientInterface + */ + public function addMessages($queueName, $messages, $priority = null) + { + foreach ($messages as $message) { + $this->addMessage($queueName, $message, $priority); + } + + return $this; + } + + /** + * @param string $queueName + * @param mixed $message + * @param string $priority + * + * @return AdapterInterface + */ + public function addMessage($queueName, $message, $priority = null) + { + return $this; + } + } diff --git a/src/Adapter/NullAdapter.php b/src/Adapter/NullAdapter.php index 04664e1..f1b904d 100644 --- a/src/Adapter/NullAdapter.php +++ b/src/Adapter/NullAdapter.php @@ -23,14 +23,6 @@ public function __construct(PriorityHandlerInterface $priorityHandler = null) $this->priorityHandler = $priorityHandler; } - /** - * @inheritdoc - */ - public function addMessage($queueName, $message, $priority = null) - { - return $this; - } - /** * @inheritdoc */ diff --git a/src/QueueClient.php b/src/QueueClient.php index c308262..9c38f6f 100644 --- a/src/QueueClient.php +++ b/src/QueueClient.php @@ -70,9 +70,7 @@ public function addMessages($queueName, $messages, $priority = null) $queues = (array) $this->resolveAliasQueueName($queueName); foreach ($queues as $queue) { - foreach ($messages as $message) { - $this->adapter->addMessage($queue, $message, $priority); - } + $this->adapter->addMessages($queue, $messages, $priority); } return $this;