Flow::getCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Flow.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:MQTTClient!
9
 * @subpackage     React
10
 * @since          1.0.0
11
 *
12
 * @date           12.03.17
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\MQTTClient\React;
18
19
use React\Promise;
20
21
use BinSoul\Net\Mqtt;
22
23
/**
24
 * Decorates flows with data required for the Client class
25
 *
26
 * @package        iPublikuj:MQTTClient!
27
 * @subpackage     React
28
 *
29
 * @author         Adam Kadlec <[email protected]>
30
 */
31
final class Flow implements Mqtt\Flow
32
{
33
	/**
34
	 * @var Flow
35
	 */
36
	private $decorated;
37
38
	/**
39
	 * @var Promise\Deferred
40
	 */
41
	private $deferred;
42
43
	/**
44
	 * @var Mqtt\Packet
45
	 */
46
	private $packet;
47
48
	/**
49
	 * @var bool
50
	 */
51
	private $isSilent;
52
53
	/**
54
	 * Constructs an instance of this class.
55
	 *
56
	 * @param Mqtt\Flow $decorated
57
	 * @param Promise\Deferred $deferred
58
	 * @param Mqtt\Packet $packet
59
	 * @param bool $isSilent
60
	 */
61
	public function __construct(
62
		Mqtt\Flow $decorated,
63
		Promise\Deferred $deferred,
64
		Mqtt\Packet $packet = NULL,
65
		bool $isSilent = FALSE
66
	) {
67
		$this->decorated = $decorated;
0 ignored issues
show
Documentation Bug introduced by
$decorated is of type object<BinSoul\Net\Mqtt\Flow>, but the property $decorated was declared to be of type object<IPub\MQTTClient\React\Flow>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
68
		$this->deferred = $deferred;
69
		$this->packet = $packet;
70
		$this->isSilent = $isSilent;
71
	}
72
73
	/**
74
	 * {@inheritdoc}
75
	 */
76
	public function getCode()
77
	{
78
		return $this->decorated->getCode();
79
	}
80
81
	/**
82
	 * {@inheritdoc}
83
	 */
84
	public function start()
85
	{
86
		$this->packet = $this->decorated->start();
87
88
		return $this->packet;
89
	}
90
91
	/**
92
	 * {@inheritdoc}
93
	 */
94
	public function accept(Mqtt\Packet $packet)
95
	{
96
		return $this->decorated->accept($packet);
97
	}
98
99
	/**
100
	 * {@inheritdoc}
101
	 */
102
	public function next(Mqtt\Packet $packet)
103
	{
104
		$this->packet = $this->decorated->next($packet);
105
106
		return $this->packet;
107
	}
108
109
	/**
110
	 * {@inheritdoc}
111
	 */
112
	public function isFinished()
113
	{
114
		return $this->decorated->isFinished();
115
	}
116
117
	/**
118
	 * {@inheritdoc}
119
	 */
120
	public function isSuccess()
121
	{
122
		return $this->decorated->isSuccess();
123
	}
124
125
	/**
126
	 * {@inheritdoc}
127
	 */
128
	public function getResult()
129
	{
130
		return $this->decorated->getResult();
131
	}
132
133
	/**
134
	 * {@inheritdoc}
135
	 */
136
	public function getErrorMessage()
137
	{
138
		return $this->decorated->getErrorMessage();
139
	}
140
141
	/**
142
	 * Returns the associated deferred
143
	 *
144
	 * @return Promise\Deferred
145
	 */
146
	public function getDeferred() : Promise\Deferred
147
	{
148
		return $this->deferred;
149
	}
150
151
	/**
152
	 * Returns the current packet
153
	 *
154
	 * @return Mqtt\Packet
155
	 */
156
	public function getPacket() : Mqtt\Packet
157
	{
158
		return $this->packet;
159
	}
160
161
	/**
162
	 * Indicates if the flow should emit events
163
	 *
164
	 * @return bool
165
	 */
166
	public function isSilent() : bool
167
	{
168
		return $this->isSilent;
169
	}
170
}
171