Completed
Push — master ( b2dfe1...1412d2 )
by Sam
02:32
created

AbstractMessage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 58
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getType() 0 4 1
A getPayload() 0 4 1
A jsonSerialize() 0 7 1
1
<?php
2
3
namespace Jalle19\StatusManager\Message;
4
5
/**
6
 * Base class for messages that can be sent between the server and the clients
7
 *
8
 * @package   Jalle19\StatusManager
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
abstract class AbstractMessage implements \JsonSerializable
13
{
14
15
	const TYPE_STATUS_UPDATES              = 'statusUpdates';
16
	const TYPE_STATISTICS_POPULAR_CHANNELS = 'statisticsPopularChannels';
17
18
	/**
19
	 * @var string
20
	 */
21
	private $_type;
22
23
	/**
24
	 * @var mixed
25
	 */
26
	private $_payload;
27
28
29
	/**
30
	 * @param string $type
31
	 * @param mixed  $payload
32
	 */
33
	public function __construct($type, $payload)
34
	{
35
		$this->_type    = $type;
36
		$this->_payload = $payload;
37
	}
38
39
40
	/**
41
	 * @return string
42
	 */
43
	public function getType()
44
	{
45
		return $this->_type;
46
	}
47
48
49
	/**
50
	 * @return mixed
51
	 */
52
	public function getPayload()
53
	{
54
		return $this->_payload;
55
	}
56
57
58
	/**
59
	 * @inheritdoc
60
	 */
61
	public function jsonSerialize()
62
	{
63
		return [
64
			'type'    => $this->_type,
65
			'payload' => $this->_payload,
66
		];
67
	}
68
69
}
70