Completed
Push — 1.0 ( 3cba8a...ca5b13 )
by David
04:07
created

Binding   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 143
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 11
c 2
b 0
f 1
lcom 1
cbo 3
dl 0
loc 143
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __contruct() 0 4 1
A init() 0 15 2
A getRoutingKey() 0 3 1
A setRoutingKey() 0 4 1
A getNowait() 0 3 1
A setNowait() 0 4 1
A getArguments() 0 3 1
A setArguments() 0 4 1
A getTicket() 0 3 1
A setTicket() 0 4 1
1
<?php
2
namespace Mouf\AmqpClient\Objects;
3
4
use Mouf\AmqpClient\RabbitMqObjectInterface;
5
use PhpAmqpLib\Connection\AMQPStreamConnection;
6
use PhpAmqpLib\Channel\AMQPChannel;
7
8
class Binding implements RabbitMqObjectInterface{
9
	
10
	/**
11
	 * 
12
	 * @var Exchange
13
	 */
14
	private $source;
15
	
16
	/**
17
	 * Routing key
18
	 * @var string
19
	 */
20
	private $routing_key = '';
21
	
22
	/**
23
	 * No wait
24
	 * @var bool
25
	 */
26
	private $nowait = false;
27
	
28
	/**
29
	 * Arguments
30
	 * @var array
31
	 */
32
	private $arguments = null;
33
	
34
	/**
35
	 * Ticket
36
	 * @var int
37
	 */
38
	private $ticket = 0;
39
	
40
	/**
41
	 *
42
	 * @var Queue
43
	 */
44
	private $to;
45
	
46
	/**
47
	 * Parameter to initialize object only one time
48
	 * @var bool
49
	 */
50
	private $init = false;
51
	
52
	/**
53
	 * Set the source (Exchange) to the destination (Queue)
54
	 * @param Exchange $source
55
	 * @param Queue $to
56
	 */
57
	public function __contruct(Exchange $source, Queue $to) {
58
		$this->source = $source;
59
		$this->to = $to;
60
	}
61
	
62
	public function init(AMQPChannel $amqpChannel) {
63
		if(!$this->init) {
64
			$this->source->init();
0 ignored issues
show
Bug introduced by
The call to init() misses a required argument $amqpChannel.

This check looks for function calls that miss required arguments.

Loading history...
65
			$this->to->init();
0 ignored issues
show
Bug introduced by
The call to init() misses a required argument $amqpChannel.

This check looks for function calls that miss required arguments.

Loading history...
66
			
67
			$amqpChannel->queue_bind($this->to->getName(),
0 ignored issues
show
Bug introduced by
The method getName() does not seem to exist on object<Mouf\AmqpClient\Objects\Queue>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68
										$this->source->getName(),
69
										$this->routing_key,
70
										$this->nowait,
71
										$this->arguments,
72
										$this->ticket);
73
			
74
			$this->init = true;
75
		}
76
	}
77
	
78
	/**
79
	 * Get Routing key
80
	 * @return string
81
	 */
82
	public function getRoutingKey() {
83
		return $this->routing_key;
84
	}
85
	
86
	/**
87
	 * Set routing key
88
	 * @param string $routing_key
89
	 * @return Binding
90
	 */
91
	public function setRoutingKey($routing_key) {
92
		$this->routing_key = $routing_key;
93
		return $this;
94
	}
95
	
96
	/**
97
	 * Get nowait
98
	 * @return bool
99
	 */
100
	public function getNowait() {
101
		return $this->nowait;
102
	}
103
	
104
	/**
105
	 * Set nowait
106
	 * @param bool $nowait
107
	 * @return Binding
108
	 */
109
	public function setNowait($nowait) {
110
		$this->nowait = $nowait;
111
		return $this;
112
	}
113
	
114
	/**
115
	 * Get arguments
116
	 * @return array
117
	 */
118
	public function getArguments() {
119
		return $this->arguments;
120
	}
121
	
122
	/**
123
	 * Set arguments
124
	 * @param bool $arguments
125
	 * @return Binding
126
	 */
127
	public function setArguments(array $arguments) {
128
		$this->arguments = $arguments;
129
		return $this;
130
	}
131
	
132
	/**
133
	 * Get ticket
134
	 * @return int
135
	 */
136
	public function getTicket() {
137
		return $this->ticket;
138
	}
139
	
140
	/**
141
	 * Set ticket
142
	 * @param int $ticket
143
	 * @return Binding
144
	 */
145
	public function setTicket($ticket) {
146
		$this->ticket = $ticket;
147
		return $this;
148
	}
149
	
150
}