| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| 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 | 4 | public function __construct(AMQPChannel $channel, string $queue, string $exchange, bool $persistant) |
|
| 25 | { |
||
| 26 | 4 | $this->channel = $channel; |
|
| 27 | 4 | $this->queue = $queue; |
|
| 28 | 4 | $this->exchange = $exchange; |
|
| 29 | 4 | $this->persistant = $persistant; |
|
| 30 | |||
| 31 | 4 | $this->channel->queue_declare($this->queue, false, $this->persistant, false, false); |
|
| 32 | 4 | $this->channel->queue_bind($this->queue, $this->exchange, $this->queue); |
|
| 33 | 4 | } |
|
| 34 | |||
| 35 | 1 | public function publish(Message $message, int $batchCount) |
|
| 42 | } |
||
| 43 | 1 | } |
|
| 44 | |||
| 45 | 1 | public function finalize() |
|
| 46 | { |
||
| 47 | 1 | $this->flush(); |
|
| 48 | 1 | } |
|
| 49 | |||
| 50 | 2 | public function flush() |
|
| 51 | { |
||
| 52 | 2 | $this->channel->publish_batch(); |
|
| 53 | 2 | } |
|
| 54 | |||
| 55 | 1 | public function countMessages(): int |
|
| 56 | { |
||
| 57 | 1 | return $this->channel->queue_declare($this->queue, true)[1]; |
|
| 58 | } |
||
| 59 | |||
| 60 | 1 | private function buildMessage(Message $message) |
|
| 63 | } |
||
| 64 | } |
||
| 65 |