Completed
Push — master ( 041b39...d19341 )
by Sam
02:48
created

StateChange   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 76.92%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 67
ccs 10
cts 13
cp 0.7692
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscriptionId() 0 4 1
A getState() 0 4 1
A setState() 0 4 1
A jsonSerialize() 0 7 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
	public function jsonSerialize()
71
	{
72
		return [
73
			'subscriptionId' => $this->_subscriptionId,
74
			'state'          => $this->_state,
75
		];
76
	}
77
78
}
79