Completed
Push — master ( eeb5e0...9f7a88 )
by Sam
04:08
created

Instance   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 45%

Importance

Changes 0
Metric Value
wmc 7
lcom 2
cbo 1
dl 0
loc 95
ccs 9
cts 20
cp 0.45
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getName() 0 4 1
A getIgnoredUsers() 0 4 1
A setIgnoredUsers() 0 4 1
A setCredentials() 0 4 1
A getInstance() 0 4 1
A jsonSerialize() 0 6 1
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