Completed
Push — master ( f61da2...430ae5 )
by Sam
03:08
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 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
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
	public function __construct($name, $address, $port)
40
	{
41
		$this->_name = $name;
42
43
		// Create the actual instance
44
		$this->_instance = new Tvheadend($address, $port);
45
	}
46
47
48
	/**
49
	 * @return string
50
	 */
51 1
	public function getName()
52
	{
53 1
		return $this->_name;
54
	}
55
56
57
	/**
58
	 * @return array
59
	 */
60
	public function getIgnoredUsers()
61
	{
62
		return $this->_ignoredUsers;
63
	}
64
65
66
	/**
67
	 * @param array $ignoredUsers
68
	 */
69
	public function setIgnoredUsers($ignoredUsers)
70
	{
71
		$this->_ignoredUsers = $ignoredUsers;
72
	}
73
74
75
	/**
76
	 * Sets the credentials to use
77
	 *
78
	 * @param $username
79
	 * @param $password
80
	 */
81
	public function setCredentials($username, $password)
82
	{
83
		$this->_instance->setCredentials($username, $password);
84
	}
85
86
87
	/**
88
	 * @return Tvheadend
89
	 */
90
	public function getInstance()
91
	{
92
		return $this->_instance;
93
	}
94
95
96
	/**
97
	 * @inheritdoc
98
	 */
99
	public function jsonSerialize()
100
	{
101
		return [
102
			'name' => $this->getName(),
103
		];
104
	}
105
106
}
107