Completed
Push — master ( 035d35...799922 )
by Sam
03:35
created

Instance::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 2
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Jalle19\StatusManager\Configuration;
4
5
use Jalle19\tvheadend\Tvheadend;
6
7
/**
8
 * Class Instance
9
 * @package   Jalle19\StatusManager\Configuration
10
 * @copyright Copyright &copy; Sam Stenvall 2015-
11
 * @license   https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0
12
 */
13
class Instance implements \JsonSerializable
14
{
15
16
	/**
17
	 * @var string the name of the instance
18
	 */
19
	private $_name;
20
21
	/**
22
	 * @var array the names of users whose subscriptions should be ignored
23
	 */
24
	private $_ignoredUsers;
25
26
	/**
27
	 * @var Tvheadend the actual tvheadend instance
28
	 */
29
	private $_instance;
30
31
32
	/**
33
	 * Instance constructor.
34
	 *
35
	 * @param string $name
36
	 * @param string $address
37
	 * @param int    $port
38
	 */
39 1
	public function __construct($name, $address, $port)
40
	{
41 1
		$this->_name         = $name;
42 1
		$this->_ignoredUsers = [];
43
44
		// Create the actual instance
45 1
		$this->_instance = new Tvheadend($address, $port);
46 1
	}
47
48
49
	/**
50
	 * @return string
51
	 */
52 2
	public function getName()
53
	{
54 2
		return $this->_name;
55
	}
56
57
58
	/**
59
	 * @return array
60
	 */
61 1
	public function getIgnoredUsers()
62
	{
63 1
		return $this->_ignoredUsers;
64
	}
65
66
67
	/**
68
	 * @param array $ignoredUsers
69
	 */
70
	public function setIgnoredUsers($ignoredUsers)
71
	{
72
		$this->_ignoredUsers = $ignoredUsers;
73
	}
74
75
76
	/**
77
	 * Sets the credentials to use
78
	 *
79
	 * @param $username
80
	 * @param $password
81
	 */
82
	public function setCredentials($username, $password)
83
	{
84
		$this->_instance->setCredentials($username, $password);
85
	}
86
87
88
	/**
89
	 * @return Tvheadend
90
	 */
91
	public function getInstance()
92
	{
93
		return $this->_instance;
94
	}
95
96
97
	/**
98
	 * @inheritdoc
99
	 */
100
	public function jsonSerialize()
101
	{
102
		return [
103
			'name' => $this->getName(),
104
		];
105
	}
106
107
}
108