JobBindingToExchangeCreate::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 8
Ratio 61.54 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 4
crap 2
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\RoutingKey;
8
use mcorten87\rabbitmq_api\objects\VirtualHost;
9
10 View Code Duplication
class JobBindingToExchangeCreate 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...
11
{
12
    /**
13
     * @var VirtualHost
14
     */
15
    private $virtualHost;
16
17
18
    /**
19
     * @var ExchangeName
20
     */
21
    private $exchange;
22
23
    /**
24
     * @var ExchangeName
25
     */
26
    private $toExchange;
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 1
    public function getVirtualHost() : VirtualHost
42
    {
43 1
        return $this->virtualHost;
44
    }
45
46
    /**
47
     * @return ExchangeName
48
     */
49 1
    public function getExchangeName()
50
    {
51 1
        return $this->exchange;
52
    }
53
54
    /**
55
     * @return ExchangeName
56
     */
57 1
    public function getToExchange(): ExchangeName
58
    {
59 1
        return $this->toExchange;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 1
    public function getDestinationType(): string
66
    {
67 1
        return (string)$this->destinationType;
68
    }
69
70
    /**
71
     * @return mixed
72
     */
73 2
    public function getRoutingKey()
74
    {
75 2
        return $this->routingKey;
76
    }
77
78
    /**
79
     * JobBindingToExchangeCreate constructor.
80
     * @param VirtualHost $virtualHost
81
     * @param ExchangeName $exchange
82
     * @param ExchangeName $to
83
     * @param RoutingKey|null $routingKey
84
     */
85 2
    public function __construct(
86
        VirtualHost $virtualHost,
87
        ExchangeName $exchange,
88
        ExchangeName $to,
89
        RoutingKey $routingKey = null
90
    ) {
91 2
        $this->virtualHost = $virtualHost;
92 2
        $this->exchange = $exchange;
93 2
        $this->toExchange = $to;
94
95 2
        $this->destinationType = new DestinationType(DestinationType::EXCHANGE);
96 2
        $this->routingKey = $routingKey !== null ? $routingKey : new RoutingKey('');
97 2
    }
98
}
99