StateChange   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 63
rs 10
ccs 13
cts 13
cp 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getState() 0 3 1
A jsonSerialize() 0 5 1
A getSubscriptionId() 0 3 1
A setState() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Jalle19\StatusManager\Subscription;
4
5
/**
6
 * Represents a subscription state change
7
 *
8
 * @package   Jalle19\StatusManager\Subscription
9
 * @copyright Copyright &copy; Sam Stenvall 2016-
10
 * @license   https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0
11
 */
12
class StateChange implements \JsonSerializable
13
{
14
15
	const STATE_SUBSCRIPTION_STARTED = 'started';
16
	const STATE_SUBSCRIPTION_STOPPED = 'stopped';
17
18
	/**
19
	 * @var int
20
	 */
21
	private $_subscriptionId;
22
23
	/**
24
	 * @var string
25
	 */
26
	private $_state;
27
28
29
	/**
30
	 * StateChange constructor
31
	 *
32
	 * @param int $subscriptionId
33
	 */
34 2
	public function __construct($subscriptionId)
35
	{
36 2
		$this->_subscriptionId = $subscriptionId;
37 2
	}
38
39
40
	/**
41
	 * @return int
42
	 */
43 2
	public function getSubscriptionId()
44
	{
45 2
		return $this->_subscriptionId;
46
	}
47
48
49
	/**
50
	 * @return string
51
	 */
52 2
	public function getState()
53
	{
54 2
		return $this->_state;
55
	}
56
57
58
	/**
59
	 * @param string $state
60
	 */
61 2
	public function setState($state)
62
	{
63 2
		$this->_state = $state;
64 2
	}
65
66
67
	/**
68
	 * @inheritdoc
69
	 */
70 2
	public function jsonSerialize()
71
	{
72
		return [
73 2
			'subscriptionId' => $this->_subscriptionId,
74 2
			'state'          => $this->_state,
75 2
		];
76
	}
77
78
}
79