Completed
Push — master ( f97b5b...252fb7 )
by Sam
02:27
created

PopularChannelsRequest::__construct()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.2
cc 4
eloc 7
nc 3
nop 1
1
<?php
2
3
namespace Jalle19\StatusManager\Message\Request;
4
5
use Jalle19\StatusManager\Exception\MalformedRequestException;
6
use Jalle19\StatusManager\Message\AbstractMessage;
7
8
/**
9
 * Class PopularChannelsRequest
10
 * @package   Jalle19\StatusManager\Message\Request
11
 * @copyright Copyright &copy; Sam Stenvall 2016-
12
 * @license   https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0
13
 */
14
class PopularChannelsRequest extends AbstractMessage
15
{
16
17
	/**
18
	 * @var string
19
	 */
20
	private $_instanceName;
21
22
	/**
23
	 * @var int
24
	 */
25
	private $_limit;
26
27
28
	/**
29
	 * PopularChannelsRequest constructor.
30
	 *
31
	 * @param string $parameters
32
	 *
33
	 * @throws MalformedRequestException
34
	 */
35
	public function __construct($parameters)
36
	{
37
		parent::__construct(self::TYPE_POPULAR_CHANNELS_REQUEST, $parameters);
38
39
		/* @var \stdClass $parameters */
40
		if (!isset($parameters->instanceName) || empty($parameters->instanceName))
41
			throw new MalformedRequestException('Missing mandatory "instanceName" parameter');
42
43
		$this->_instanceName = $parameters->instanceName;
44
45
		if (isset($parameters->limit))
46
			$this->_limit = $parameters->limit;
47
	}
48
49
50
	/**
51
	 * @return string
52
	 */
53
	public function getInstanceName()
54
	{
55
		return $this->_instanceName;
56
	}
57
58
59
	/**
60
	 * @return int
61
	 */
62
	public function getLimit()
63
	{
64
		return $this->_limit;
65
	}
66
67
}
68