Passed
Branch master (74fab5)
by Kunal
03:19
created

RabbitMQMessageConsumer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Kunnu\RabbitMQ;
4
5
use Illuminate\Support\Collection;
6
7
abstract class RabbitMQMessageConsumer
8
{
9
    protected Collection $config;
10
11
    protected ?RabbitMQExchange $exchange = null;
12
13
    protected ?RabbitMQQueue $queue = null;
14
15
    public function __construct(array $config = [])
16
    {
17
        $this->setConfig($config);
18
    }
19
20
    /**
21
     * Handle an incoming message.
22
     *
23
     * @param RabbitMQIncomingMessage $message
24
     * @return void
25
     */
26
    abstract public function handle(RabbitMQIncomingMessage $message): void;
27
28
    /**
29
     * Get config.
30
     *
31
     * @return Collection
32
     */
33
    public function getConfig(): Collection
34
    {
35
        return $this->config;
36
    }
37
38
    /**
39
     * Set configuration.
40
     *
41
     * @param array $config
42
     * @return self
43
     */
44
    public function setConfig(array $config): self
45
    {
46
        $this->config = new Collection($config);
47
48
        return $this;
49
    }
50
51
    /**
52
     * @return null|\Kunnu\RabbitMQ\RabbitMQExchange|null
53
     */
54
    public function getExchange(): ?RabbitMQExchange
55
    {
56
        return $this->exchange;
57
    }
58
59
    /**
60
     * @param \Kunnu\RabbitMQ\RabbitMQExchange|null $exchange
61
     *
62
     * @return self
63
     */
64
    public function setExchange(?RabbitMQExchange $exchange): self
65
    {
66
        $this->exchange = $exchange;
67
68
        return $this;
69
    }
70
71
    /**
72
     * @return null|\Kunnu\RabbitMQ\RabbitMQQueue|null
73
     */
74
    public function getQueue(): ?RabbitMQQueue
75
    {
76
        return $this->queue;
77
    }
78
79
    /**
80
     * @param \Kunnu\RabbitMQ\RabbitMQQueue|null $queue
81
     *
82
     * @return self
83
     */
84
    public function setQueue(?RabbitMQQueue $queue): self
85
    {
86
        $this->queue = $queue;
87
88
        return $this;
89
    }
90
}
91