Total Complexity | 10 |
Total Lines | 84 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | trait RabbitTrait |
||
11 | { |
||
12 | /** @var string $queue */ |
||
13 | private $queue; |
||
14 | |||
15 | /** @var string $exchanger */ |
||
16 | private $exchanger; |
||
17 | |||
18 | /** @var bool $reply */ |
||
19 | private $reply; |
||
20 | |||
21 | /** |
||
22 | * @param string $queue |
||
23 | * @return self |
||
24 | */ |
||
25 | protected function setQueue(string $queue): self |
||
26 | { |
||
27 | $queue = trim($queue); |
||
28 | |||
29 | if (empty($queue)) { |
||
30 | throw new \InvalidArgumentException("Fila inválida!"); |
||
31 | } |
||
32 | |||
33 | if (!filter_var($queue)) { |
||
34 | throw new \InvalidArgumentException("Fila inválida!"); |
||
35 | } |
||
36 | |||
37 | $this->queue = $queue; |
||
38 | return $this; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param string $queue |
||
43 | * @return self |
||
44 | */ |
||
45 | protected function setExchanger(string $exchanger): self |
||
46 | { |
||
47 | $exchanger = trim($exchanger); |
||
48 | |||
49 | if (empty($exchanger)) { |
||
50 | throw new \InvalidArgumentException("Exchanger '{$exchanger}' inválido!"); |
||
51 | } |
||
52 | |||
53 | if (!filter_var($exchanger)) { |
||
54 | throw new \InvalidArgumentException("Exchanger '{$exchanger}' inválido!"); |
||
55 | } |
||
56 | |||
57 | $this->exchanger = $exchanger; |
||
58 | return $this; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param string $queue |
||
63 | * @return self |
||
64 | */ |
||
65 | protected function setReply(bool $reply): self |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return null|string |
||
74 | */ |
||
75 | public function getQueue(): ?string |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return null|string |
||
82 | */ |
||
83 | public function getExchanger(): ?string |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @return null|bool |
||
90 | */ |
||
91 | public function getReply(): ?bool |
||
96 |