1 | <?php |
||
2 | |||
3 | namespace Kunnu\RabbitMQ; |
||
4 | |||
5 | use Illuminate\Support\Collection; |
||
6 | |||
7 | class RabbitMQExchange |
||
8 | { |
||
9 | /** |
||
10 | * Exchange name. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected string $name; |
||
15 | |||
16 | /** |
||
17 | * Exchange config. |
||
18 | * |
||
19 | * @var Collection |
||
20 | */ |
||
21 | protected Collection $config; |
||
22 | |||
23 | /** |
||
24 | * Create a new RabbitMQ Exchange instance. |
||
25 | * |
||
26 | * @param string $name |
||
27 | * @param array $config |
||
28 | */ |
||
29 | public function __construct(string $name, array $config = []) |
||
30 | { |
||
31 | $this |
||
32 | ->setName($name) |
||
33 | ->setConfig($config); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Get Exchange name. |
||
38 | * |
||
39 | * @return string |
||
40 | */ |
||
41 | public function getName(): string |
||
42 | { |
||
43 | return $this->name; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Set Exchange name. |
||
48 | * |
||
49 | * @param string $name |
||
50 | * @return RabbitMQExchange |
||
51 | */ |
||
52 | public function setName(string $name): self |
||
53 | { |
||
54 | $this->name = $name; |
||
55 | |||
56 | return $this; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Get Exchange Config. |
||
61 | * |
||
62 | * @return Collection |
||
63 | */ |
||
64 | public function getConfig(): Collection |
||
65 | { |
||
66 | return $this->config; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Set Exchange config. |
||
71 | * |
||
72 | * @param array $config |
||
73 | * @return RabbitMQExchange |
||
74 | */ |
||
75 | public function setConfig(array $config): self |
||
76 | { |
||
77 | $this->config = new Collection($config); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
78 | |||
79 | return $this; |
||
80 | } |
||
81 | } |
||
82 |