Total Complexity | 9 |
Total Lines | 109 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | class RabbitMQMessage |
||
9 | { |
||
10 | /** |
||
11 | * Message stream. |
||
12 | * |
||
13 | * @var string $stream |
||
14 | */ |
||
15 | protected string $stream; |
||
16 | |||
17 | /** |
||
18 | * Message exchange. |
||
19 | * |
||
20 | * @var RabbitMQExchange|null $exchange |
||
21 | */ |
||
22 | protected ?RabbitMQExchange $exchange = null; |
||
23 | |||
24 | /** |
||
25 | * Message config. |
||
26 | * |
||
27 | * @var Collection $config |
||
28 | */ |
||
29 | protected Collection $config; |
||
30 | |||
31 | /** |
||
32 | * Create a new RabbitMQ Message instance. |
||
33 | * |
||
34 | * @param string $stream |
||
35 | * @param array $config |
||
36 | */ |
||
37 | public function __construct(string $stream, array $config = []) |
||
38 | { |
||
39 | $this |
||
40 | ->setStream($stream) |
||
41 | ->setConfig($config); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Set message config. |
||
46 | * |
||
47 | * @param array $config |
||
48 | * |
||
49 | * @return RabbitMQMessage |
||
50 | */ |
||
51 | public function setConfig(array $config): self |
||
52 | { |
||
53 | $this->config = new Collection($config); |
||
54 | |||
55 | return $this; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Get AMQP Message. |
||
60 | * |
||
61 | * @return AMQPMessage |
||
62 | */ |
||
63 | public function getAmqpMessage(): AMQPMessage |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Set message stream. |
||
70 | * |
||
71 | * @param string $stream |
||
72 | * @return self |
||
73 | */ |
||
74 | public function setStream(string $stream): self |
||
75 | { |
||
76 | $this->stream = $stream; |
||
77 | |||
78 | return $this; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getStream(): string |
||
85 | { |
||
86 | return $this->stream; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @return Collection |
||
91 | */ |
||
92 | public function getConfig(): Collection |
||
93 | { |
||
94 | return $this->config; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @return null|RabbitMQExchange |
||
99 | */ |
||
100 | public function getExchange(): ?RabbitMQExchange |
||
101 | { |
||
102 | return $this->exchange; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Set message exchange. |
||
107 | * |
||
108 | * @param RabbitMQExchange $exchange |
||
109 | * |
||
110 | * @return self |
||
111 | */ |
||
112 | public function setExchange(RabbitMQExchange $exchange): self |
||
117 | } |
||
118 | } |
||
119 |