Container::getPublishers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Author: Joker
4
 * Date: 2020-05-08 13:57
5
 */
6
7
namespace JokerProject\LaravelAliyunAmqp;
8
9
use JokerProject\LaravelAliyunAmqp\ConsumerInterface;
10
use JokerProject\LaravelAliyunAmqp\PublisherInterface;
11
12
/**
13
 * Class Container
14
 *
15
 * @package JokerProject\LaravelAliyunAmqp
16
 * @author  Adrian Tilita <[email protected]>
17
 */
18
class Container
19
{
20
    /**
21
     * @var array
22
     */
23
    private $publishers = [];
24
25
    /**
26
     * @var array
27
     */
28
    private $consumers = [];
29
30
    /**
31
     * @param string $publisherName
32
     * @param PublisherInterface $entity
33
     * @return Container
34
     */
35
    public function addPublisher(string $publisherName, PublisherInterface $entity): Container
36
    {
37
        $this->publishers[$publisherName] = $entity;
38
        return $this;
39
    }
40
41
    /**
42
     * @param string $publisherName
43
     * @return PublisherInterface
44
     */
45
    public function getPublisher(string $publisherName): PublisherInterface
46
    {
47
        return $this->publishers[$publisherName];
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function getPublishers(): array
54
    {
55
        return $this->publishers;
56
    }
57
58
    /**
59
     * @param string $publisherName
60
     * @return bool
61
     */
62
    public function hasPublisher(string $publisherName): bool
63
    {
64
        return isset($this->publishers[$publisherName]);
65
    }
66
67
    /**
68
     * @param string $consumerName
69
     * @param ConsumerInterface $consumer
70
     * @return Container
71
     */
72
    public function addConsumer(string $consumerName, ConsumerInterface $consumer): Container
73
    {
74
        $this->consumers[$consumerName] = $consumer;
75
        return $this;
76
    }
77
78
    /**
79
     * @param string $consumerName
80
     * @return mixed
81
     */
82
    public function getConsumer(string $consumerName)
83
    {
84
        return $this->consumers[$consumerName];
85
    }
86
87
    /**
88
     * @return array
89
     */
90
    public function getConsumers(): array
91
    {
92
        return $this->consumers;
93
    }
94
95
    /**
96
     * @param string $consumerName
97
     * @return bool
98
     */
99
    public function hasConsumer(string $consumerName): bool
100
    {
101
        return isset($this->consumers[$consumerName]);
102
    }
103
}
104