Completed
Push — master ( 9186fa...c4ad81 )
by Tilita
16s queued 14s
created

Container::getPublisher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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