| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class AmqpMessagePublisher implements MessagePublisherInterface |
||
| 12 | { |
||
| 13 | /** @var AMQPChannel */ |
||
| 14 | private $channel; |
||
| 15 | /** @var string */ |
||
| 16 | private $queue; |
||
| 17 | /** @var string */ |
||
| 18 | private $exchange; |
||
| 19 | /** @var int */ |
||
| 20 | private $batch = 0; |
||
| 21 | /** @var bool */ |
||
| 22 | private $persistant; |
||
| 23 | |||
| 24 | public function __construct(AMQPChannel $channel, string $queue, string $exchange, bool $persistant) |
||
| 25 | { |
||
| 26 | $this->channel = $channel; |
||
| 27 | $this->queue = $queue; |
||
| 28 | $this->exchange = $exchange; |
||
| 29 | $this->persistant = $persistant; |
||
| 30 | |||
| 31 | $this->channel->queue_declare($this->queue, false, $this->persistant, false, false); |
||
| 32 | $this->channel->queue_bind($this->queue, $this->exchange, $this->queue); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function publish(Message $message, int $batchCount) |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | private function buildMessage(Message $message) |
||
| 48 | } |
||
| 49 | |||
| 50 | public function finalize() |
||
| 51 | { |
||
| 52 | $this->flush(); |
||
| 53 | } |
||
| 54 | |||
| 55 | public function flush() |
||
| 56 | { |
||
| 57 | $this->channel->publish_batch(); |
||
| 58 | } |
||
| 59 | |||
| 60 | public function countMessages(): int |
||
| 63 | } |
||
| 64 | } |
||
| 65 |