Completed
Push — master ( d28680...48d96a )
by Olivier
01:31
created

StatefulStompMessagePublisher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Swarrot\Broker\MessagePublisher;
4
5
use Stomp\Client;
6
use Stomp\StatefulStomp;
7
use Stomp\Transport\Message as StompMessage;
8
use Swarrot\Broker\Message;
9
10
/**
11
 * See http://www.rabbitmq.com/stomp.html for more infos.
12
 *
13
 * When you publish you can set different key
14
 *
15
 * to publish in the exchange {EXCHANGE_NAME}
16
 *   '/exchange/{EXCHANGE_NAME}'
17
 * to publish in the exchange {EXCHANGE_NAME} with {ROUTING_KEY}
18
 *   '/exchange/{EXCHANGE_NAME}/{ROUTING_KEY}'
19
 * to publish in queue {QUEUE_NAME} (create the queue)
20
 *   '/queue/{QUEUE_NAME}'
21
 * to publish in queue {QUEUE_NAME} (that already exist in rabbit)
22
 *   '/amq/queue/{QUEUE_NAME}'
23
 * to publish in exchange amq.topic
24
 *   '/topic/{ROUTING_KEY}'
25
 *   '/exchange/amq.topic/{ROUTING_KEY}'
26
 *
27
 * You can also use 'temp-queue' refer to the doc
28
 */
29 View Code Duplication
class StatefulStompMessagePublisher implements MessagePublisherInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
{
31
    /**
32
     * @var Client
33
     */
34
    private $client;
35
36
    /**
37
     * @var StatefulStomp
38
     */
39
    private $stomp;
40
41
    /**
42
     * @param Client $client
43
     */
44
    public function __construct(Client $client)
45
    {
46
        $this->client = $client;
47
        $this->stomp = new StatefulStomp($client);
48
    }
49
50
    /**
51
     * @param Message $message
52
     * @param null    $key
53
     */
54
    public function publish(Message $message, $key = null)
55
    {
56
        $this->stomp->send($key, new StompMessage($message->getBody(), $message->getProperties()));
57
    }
58
59
    public function getExchangeName()
60
    {
61
        return;
62
    }
63
}
64