JobBindingToQueueCreate   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 89
Duplicated Lines 93.26 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 83
loc 89
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getVirtualHost() 4 4 1
A getQueueName() 4 4 1
A getExchangeName() 4 4 1
A getDestinationType() 4 4 1
A getRoutingKey() 4 4 1
A __construct() 8 13 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace mcorten87\rabbitmq_api\jobs;
4
5
use mcorten87\rabbitmq_api\objects\DestinationType;
6
use mcorten87\rabbitmq_api\objects\ExchangeName;
7
use mcorten87\rabbitmq_api\objects\QueueName;
8
use mcorten87\rabbitmq_api\objects\RoutingKey;
9
use mcorten87\rabbitmq_api\objects\VirtualHost;
10
11 View Code Duplication
class JobBindingToQueueCreate extends JobBase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @var VirtualHost
15
     */
16
    private $virtualHost;
17
18
19
    /**
20
     * @var QueueName
21
     */
22
    private $queueName;
23
24
    /**
25
     * @var ExchangeName
26
     */
27
    private $exchangeName;
28
29
    /**
30
     * @var DestinationType
31
     */
32
    private $destinationType;
33
34
    /**
35
     * @var RoutingKey
36
     */
37
    private $routingKey;
38
39
    /**
40
     * @return VirtualHost
41
     */
42 3
    public function getVirtualHost() : VirtualHost
43
    {
44 3
        return $this->virtualHost;
45
    }
46
47
    /**
48
     * @return QueueName
49
     */
50 3
    public function getQueueName(): QueueName
51
    {
52 3
        return $this->queueName;
53
    }
54
55
    /**
56
     * @return ExchangeName
57
     */
58 3
    public function getExchangeName()
59
    {
60 3
        return $this->exchangeName;
61
    }
62
63
    /**
64
     * @return DestinationType
65
     */
66 3
    public function getDestinationType(): string
67
    {
68 3
        return (string)$this->destinationType;
69
    }
70
71
    /**
72
     * @return RoutingKey
73
     */
74 4
    public function getRoutingKey()
75
    {
76 4
        return $this->routingKey;
77
    }
78
79
    /**
80
     * JobBindingToQueueCreate constructor.
81
     * @param VirtualHost $virtualHost
82
     * @param QueueName $queueName
83
     * @param ExchangeName $exchangeName
84
     * @param RoutingKey|null $routingKey
85
     */
86 4
    public function __construct(
87
        VirtualHost $virtualHost,
88
        QueueName $queueName,
89
        ExchangeName $exchangeName,
90
        RoutingKey $routingKey = null
91
    ) {
92 4
        $this->virtualHost = $virtualHost;
93 4
        $this->queueName = $queueName;
94 4
        $this->exchangeName = $exchangeName;
95
96 4
        $this->destinationType = new DestinationType(DestinationType::QUEUE);
97 4
        $this->routingKey = $routingKey !== null ? $routingKey : new RoutingKey('');
98 4
    }
99
}
100