RabbitSender::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Source\Core\Rabbit;
4
5
use PhpAmqpLib\Message\AMQPMessage;
0 ignored issues
show
Bug introduced by
The type PhpAmqpLib\Message\AMQPMessage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * The rabbit receiver will be listening infinitefor messages in your queue
9
 *
10
 * the handler method can be overwrited by main class for handle the received messages
11
 */
12
final class RabbitSender extends Rabbit // implements Interface
13
{
14
    public function __construct(string $queue, string $exchanger)
15
    {
16
        // basic validation for the queue, valid by the trait
17
        $this->setQueue($queue);
18
19
        // basic validation for the exchanger, valid by the trait
20
        $this->setExchanger($exchanger);
21
    }
22
23
    /**
24
     * The sender will be send your text message to queue
25
     * @var string $message The message you will send
26
     */
27
    public function sendMessage(string $message)
28
    {
29
        $properties = array('content_type' => 'text/plain', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT);
30
31
        $message = str_replace("\n", "<br>", $message);
32
33
        $Buffer = new AMQPMessage($message, $properties);
34
35
        $this->getInstance($this->getQueue(), $this->getExchanger())->channel->basic_publish($Buffer, $this->getExchanger());
36
37
        $this->closeConnection();
38
    }
39
}
40