JobBindingToQueueDelete   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 88
Duplicated Lines 93.18 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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