Completed
Push — master ( d19341...3c24ea )
by Sam
02:44
created

StateChange::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 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