Test Failed
Push — master ( 983494...3bd098 )
by Joe
03:25
created
src/Cpanel.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 	public $opts;
17 17
 
18 18
 	/**
19
-	* Cpanel constructor.
20
-	*
21
-	* @param $user
22
-	* @param $pass
23
-	*/
19
+	 * Cpanel constructor.
20
+	 *
21
+	 * @param $user
22
+	 * @param $pass
23
+	 */
24 24
 	public function __construct($user, $pass)
25 25
 	{
26 26
 		$this->opts = [];
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 
33 33
 	/**
34
-	* @param $option
35
-	* @param $value
36
-	*/
34
+	 * @param $option
35
+	 * @param $value
36
+	 */
37 37
 	public function setopt($option, $value)
38 38
 	{
39 39
 		$this->opts[$option] = $value;
40 40
 	}
41 41
 
42 42
 	/**
43
-	* sets the login credentials
44
-	* @param string $user the username
45
-	* @param string $pass the password
46
-	*/
43
+	 * sets the login credentials
44
+	 * @param string $user the username
45
+	 * @param string $pass the password
46
+	 */
47 47
 	public function setCredentials($user, $pass)
48 48
 	{
49 49
 		$this->setopt(CURLOPT_USERPWD, $user.':'.$pass);
50 50
 	}
51 51
 
52 52
 	/**
53
-	* sets the output format
54
-	*
55
-	* @param string $format can be any of xml,json,yaml,simplexml
56
-	*/
53
+	 * sets the output format
54
+	 *
55
+	 * @param string $format can be any of xml,json,yaml,simplexml
56
+	 */
57 57
 	public function setFormat($format)
58 58
 	{
59 59
 		if ($format != 'xml' && $format != 'json' && $format != 'yaml' && $format != 'simplexml') {
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	}
66 66
 
67 67
 	/**
68
-	* @param string $function
69
-	* @param array $args
70
-	* @return array|mixed|void
71
-	*/
68
+	 * @param string $function
69
+	 * @param array $args
70
+	 * @return array|mixed|void
71
+	 */
72 72
 	private function get($function, $args = [])
73 73
 	{
74 74
 		if (!$function) {
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 	/**
113
-	* formats the response
114
-	* @param array $result the result array to format
115
-	* @return array the rormatted arrray
116
-	*/
113
+	 * formats the response
114
+	 * @param array $result the result array to format
115
+	 * @return array the rormatted arrray
116
+	 */
117 117
 	private function formatResult($result)
118 118
 	{
119 119
 		if (is_array($result)) {
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	}
132 132
 
133 133
 	/**
134
-	* @param $id
135
-	* @return int
136
-	*/
134
+	 * @param $id
135
+	 * @return int
136
+	 */
137 137
 	private function validateID($id)
138 138
 	{
139 139
 		if (preg_match("/^(L|P|G)?\d*$/", $id)) {
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 
146 146
 	/**
147
-	* @param $ipAddress
148
-	* @return int
149
-	*/
147
+	 * @param $ipAddress
148
+	 * @return int
149
+	 */
150 150
 	private function validateIP($ipAddress)
151 151
 	{
152 152
 		return preg_match("/^\d*\.\d*\.\d*\.\d*$/", $ipAddress);
153 153
 	}
154 154
 
155 155
 	/**
156
-	* @param $args
157
-	* @return array|mixed|void
158
-	*/
156
+	 * @param $args
157
+	 * @return array|mixed|void
158
+	 */
159 159
 	public function reactivateLicense($args)
160 160
 	{
161 161
 		if (!array_key_exists('liscid', $args)) {
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* @param $args
174
-	* @return array|mixed|void
175
-	*/
173
+	 * @param $args
174
+	 * @return array|mixed|void
175
+	 */
176 176
 	public function expireLicense($args)
177 177
 	{
178 178
 		if (!array_key_exists('liscid', $args)) {
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 	}
188 188
 
189 189
 	/**
190
-	* @param $args
191
-	* @return array|mixed|void
192
-	*/
190
+	 * @param $args
191
+	 * @return array|mixed|void
192
+	 */
193 193
 	public function extendOnetimeUpdates($args)
194 194
 	{
195 195
 		if (!array_key_exists('ip', $args)) {
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	}
205 205
 
206 206
 	/**
207
-	* @param $args
208
-	* @return array|mixed|void
209
-	*/
207
+	 * @param $args
208
+	 * @return array|mixed|void
209
+	 */
210 210
 	public function changeip($args)
211 211
 	{
212 212
 		if (!array_key_exists('oldip', $args) || !array_key_exists('newip', $args)) {
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	/**
224
-	* @param $args
225
-	* @return array|mixed|void
226
-	*/
224
+	 * @param $args
225
+	 * @return array|mixed|void
226
+	 */
227 227
 	public function requestTransfer($args)
228 228
 	{
229 229
 		if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packagegroup', $args)) {
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* @param $args
250
-	* @return array|mixed|void
251
-	*/
249
+	 * @param $args
250
+	 * @return array|mixed|void
251
+	 */
252 252
 	public function activateLicense($args)
253 253
 	{
254 254
 		if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packageid', $args)) {
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	/**
275
-	* @param $args
276
-	* @return array|mixed|void
277
-	*/
275
+	 * @param $args
276
+	 * @return array|mixed|void
277
+	 */
278 278
 	public function addPickupPass($args)
279 279
 	{
280 280
 		if (!array_key_exists('pickup', $args)) {
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 	}
286 286
 
287 287
 	/**
288
-	* @param $args
289
-	* @return array|mixed|void
290
-	*/
288
+	 * @param $args
289
+	 * @return array|mixed|void
290
+	 */
291 291
 	public function registerAuth($args)
292 292
 	{
293 293
 		if (!array_key_exists('user', $args)) {
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
 	}
311 311
 
312 312
 	/**
313
-	* return s a list of groups
314
-	*
315
-	* @return array|mixed|void
316
-	*/
313
+	 * return s a list of groups
314
+	 *
315
+	 * @return array|mixed|void
316
+	 */
317 317
 	public function fetchGroups()
318 318
 	{
319 319
 		return $this->get('XMLgroupInfo.cgi');
320 320
 	}
321 321
 
322 322
 	/**
323
-	* fetches license risk data
324
-	*
325
-	* @param array $args
326
-	* @return array|mixed|void
327
-	*/
323
+	 * fetches license risk data
324
+	 *
325
+	 * @param array $args
326
+	 * @return array|mixed|void
327
+	 */
328 328
 	public function fetchLicenseRiskData($args = [])
329 329
 	{
330 330
 		if (!array_key_exists('ip', $args)) {
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	}
340 340
 
341 341
 	/**
342
-	* gets raw license information
343
-	*
344
-	* @param array $args optional array of arguments
345
-	* @return array|mixed|void
346
-	*/
342
+	 * gets raw license information
343
+	 *
344
+	 * @param array $args optional array of arguments
345
+	 * @return array|mixed|void
346
+	 */
347 347
 	public function fetchLicenseRaw($args = [])
348 348
 	{
349 349
 		$args = array_merge(['all' => 1], $args);
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	/**
362
-	* gets license information
363
-	*
364
-	* @param array $args optional array of arguments
365
-	* @return array|mixed|void
366
-	*/
362
+	 * gets license information
363
+	 *
364
+	 * @param array $args optional array of arguments
365
+	 * @return array|mixed|void
366
+	 */
367 367
 	public function fetchLicenseId($args = [])
368 368
 	{
369 369
 		$args = array_merge(['all' => 1], $args);
@@ -379,38 +379,38 @@  discard block
 block discarded – undo
379 379
 	}
380 380
 
381 381
 	/**
382
-	* @return array|mixed|void
383
-	*/
382
+	 * @return array|mixed|void
383
+	 */
384 384
 	public function fetchPackages($expand = false)
385 385
 	{
386 386
 		return $this->get('XMLpackageInfo.cgi', ($expand === true ? ['expand' => 1] : []));
387 387
 	}
388 388
 
389 389
 	/**
390
-	* gets a list of licenses
391
-	*
392
-	* @param array $args optional arguments
393
-	* @return array|mixed|void
394
-	*/
390
+	 * gets a list of licenses
391
+	 *
392
+	 * @param array $args optional arguments
393
+	 * @return array|mixed|void
394
+	 */
395 395
 	public function fetchLicenses($args = [])
396 396
 	{
397 397
 		return $this->get('XMLlicenseInfo.cgi');
398 398
 	}
399 399
 
400 400
 	/**
401
-	* return sa list of expired licenses
402
-	* @return array|mixed|void
403
-	*/
401
+	 * return sa list of expired licenses
402
+	 * @return array|mixed|void
403
+	 */
404 404
 	public function fetchExpiredLicenses()
405 405
 	{
406 406
 		return $this->fetchLicenses(['expired' => '1']);
407 407
 	}
408 408
 
409 409
 	/**
410
-	* @param $search
411
-	* @param $xmlObj
412
-	* @return string|void
413
-	*/
410
+	 * @param $search
411
+	 * @param $xmlObj
412
+	 * @return string|void
413
+	 */
414 414
 	public function findKey($search, $xmlObj)
415 415
 	{
416 416
 		$xmlObj = (array) $xmlObj;
Please login to merge, or discard this patch.
Braces   +74 added lines, -99 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * @package Detain\Cpanel
11 11
  */
12
-class Cpanel
13
-{
12
+class Cpanel {
14 13
 	public $format;
15 14
 	public $curl;
16 15
 	public $opts;
@@ -21,8 +20,7 @@  discard block
 block discarded – undo
21 20
 	* @param $user
22 21
 	* @param $pass
23 22
 	*/
24
-	public function __construct($user, $pass)
25
-	{
23
+	public function __construct($user, $pass) {
26 24
 		$this->opts = [];
27 25
 		$this->format = 'simplexml';
28 26
 		$this->setCredentials($user, $pass);
@@ -34,8 +32,7 @@  discard block
 block discarded – undo
34 32
 	* @param $option
35 33
 	* @param $value
36 34
 	*/
37
-	public function setopt($option, $value)
38
-	{
35
+	public function setopt($option, $value) {
39 36
 		$this->opts[$option] = $value;
40 37
 	}
41 38
 
@@ -44,8 +41,7 @@  discard block
 block discarded – undo
44 41
 	* @param string $user the username
45 42
 	* @param string $pass the password
46 43
 	*/
47
-	public function setCredentials($user, $pass)
48
-	{
44
+	public function setCredentials($user, $pass) {
49 45
 		$this->setopt(CURLOPT_USERPWD, $user.':'.$pass);
50 46
 	}
51 47
 
@@ -54,12 +50,11 @@  discard block
 block discarded – undo
54 50
 	*
55 51
 	* @param string $format can be any of xml,json,yaml,simplexml
56 52
 	*/
57
-	public function setFormat($format)
58
-	{
59
-		if ($format != 'xml' && $format != 'json' && $format != 'yaml' && $format != 'simplexml') {
53
+	public function setFormat($format) {
54
+		if ($format != 'xml' && $format != 'json' && $format != 'yaml' && $format != 'simplexml') {
60 55
 			error_log('setFormat requires that the format is xml, json, yaml or simplexml');
61 56
 			return;
62
-		} else {
57
+		} else {
63 58
 			$this->format = $format;
64 59
 		}
65 60
 	}
@@ -69,25 +64,24 @@  discard block
 block discarded – undo
69 64
 	* @param array $args
70 65
 	* @return array|mixed|void
71 66
 	*/
72
-	private function get($function, $args = [])
73
-	{
74
-		if (!$function) {
67
+	private function get($function, $args = []) {
68
+		if (!$function) {
75 69
 			error_log('cPanelLicensing::get requires that a function is defined');
76 70
 			return;
77 71
 		}
78
-		if ($this->format != 'simplexml') {
72
+		if ($this->format != 'simplexml') {
79 73
 			$args['output'] = $this->format;
80 74
 		}
81 75
 		\StatisticClient::tick('CPanel', str_replace('XML', '', $function));
82 76
 		$query = 'https://manage2.cpanel.net/'.$function.'?'.http_build_query($args);
83 77
 		$this->setopt(CURLOPT_URL, $query);
84 78
 		$this->curl = curl_init();
85
-		foreach ($this->opts as $option => $value) {
79
+		foreach ($this->opts as $option => $value) {
86 80
 			curl_setopt($this->curl, $option, $value);
87 81
 		}
88 82
 		$result = curl_exec($this->curl);
89 83
 		curl_close($this->curl);
90
-		if ($result == false) {
84
+		if ($result == false) {
91 85
 			$errno = curl_errno($this->curl);
92 86
 			$error = curl_error($this->curl);
93 87
 			error_log('cPanelLicensing::get failed with error #'.$errno.' "'.$error.'"');
@@ -95,16 +89,16 @@  discard block
 block discarded – undo
95 89
 			return;
96 90
 		}
97 91
 		\StatisticClient::report('CPanel', str_replace('XML', '', $function), true, 0, '', STATISTICS_SERVER);
98
-		if ($this->format == 'simplexml') {
92
+		if ($this->format == 'simplexml') {
99 93
 			function_requirements('xml2array');
100 94
 			$result = xml2array($result, 1, 'attribute');
101
-			if (!isset($result[str_replace('.cgi', '', $function)])) {
95
+			if (!isset($result[str_replace('.cgi', '', $function)])) {
102 96
 				myadmin_log('licenses', 'warning', json_encode($result), __LINE__, __FILE__);
103 97
 			}
104 98
 			$result = $result[str_replace('.cgi', '', $function)];
105 99
 			$result = $this->formatResult($result);
106 100
 			return $result;
107
-		} else {
101
+		} else {
108 102
 			return $result;
109 103
 		}
110 104
 	}
@@ -114,14 +108,13 @@  discard block
 block discarded – undo
114 108
 	* @param array $result the result array to format
115 109
 	* @return array the rormatted arrray
116 110
 	*/
117
-	private function formatResult($result)
118
-	{
119
-		if (is_array($result)) {
120
-			foreach ($result as $key => $value) {
121
-				if (is_array($value)) {
122
-					if (isset($value['attr']) && is_array($value['attr'])) {
111
+	private function formatResult($result) {
112
+		if (is_array($result)) {
113
+			foreach ($result as $key => $value) {
114
+				if (is_array($value)) {
115
+					if (isset($value['attr']) && is_array($value['attr'])) {
123 116
 						$result[$key] = $value['attr'];
124
-					} else {
117
+					} else {
125 118
 						$result[$key] = $this->formatResult($value);
126 119
 					}
127 120
 				}
@@ -134,11 +127,10 @@  discard block
 block discarded – undo
134 127
 	* @param $id
135 128
 	* @return int
136 129
 	*/
137
-	private function validateID($id)
138
-	{
139
-		if (preg_match("/^(L|P|G)?\d*$/", $id)) {
130
+	private function validateID($id) {
131
+		if (preg_match("/^(L|P|G)?\d*$/", $id)) {
140 132
 			return 1;
141
-		} else {
133
+		} else {
142 134
 			return 0;
143 135
 		}
144 136
 	}
@@ -147,8 +139,7 @@  discard block
 block discarded – undo
147 139
 	* @param $ipAddress
148 140
 	* @return int
149 141
 	*/
150
-	private function validateIP($ipAddress)
151
-	{
142
+	private function validateIP($ipAddress) {
152 143
 		return preg_match("/^\d*\.\d*\.\d*\.\d*$/", $ipAddress);
153 144
 	}
154 145
 
@@ -156,13 +147,12 @@  discard block
 block discarded – undo
156 147
 	* @param $args
157 148
 	* @return array|mixed|void
158 149
 	*/
159
-	public function reactivateLicense($args)
160
-	{
161
-		if (!array_key_exists('liscid', $args)) {
150
+	public function reactivateLicense($args) {
151
+		if (!array_key_exists('liscid', $args)) {
162 152
 			error_log('cpanelLicensing::reactivateLicense requires that the argument array contains element liscid');
163 153
 			return;
164 154
 		}
165
-		if (!$this->validateID($args['liscid'])) {
155
+		if (!$this->validateID($args['liscid'])) {
166 156
 			error_log('The liscid passed to cpanelLicenseing::reactivateLicense was invalid');
167 157
 			return;
168 158
 		}
@@ -173,13 +163,12 @@  discard block
 block discarded – undo
173 163
 	* @param $args
174 164
 	* @return array|mixed|void
175 165
 	*/
176
-	public function expireLicense($args)
177
-	{
178
-		if (!array_key_exists('liscid', $args)) {
166
+	public function expireLicense($args) {
167
+		if (!array_key_exists('liscid', $args)) {
179 168
 			error_log('cPanelLicensing::expireLicense requires that liscid elements exists in the array passed to it');
180 169
 			return;
181 170
 		}
182
-		if (!$this->validateID($args['liscid'])) {
171
+		if (!$this->validateID($args['liscid'])) {
183 172
 			error_log('the liscense ID passed to cpanelLicensing::expireLiscense was invalid');
184 173
 			return;
185 174
 		}
@@ -190,13 +179,12 @@  discard block
 block discarded – undo
190 179
 	* @param $args
191 180
 	* @return array|mixed|void
192 181
 	*/
193
-	public function extendOnetimeUpdates($args)
194
-	{
195
-		if (!array_key_exists('ip', $args)) {
182
+	public function extendOnetimeUpdates($args) {
183
+		if (!array_key_exists('ip', $args)) {
196 184
 			error_log('cpanelLicensing::extendOnetimeUpdates requires that the element ip exists in the array is passed to it');
197 185
 			return;
198 186
 		}
199
-		if (!$this->validateIP($args['ip'])) {
187
+		if (!$this->validateIP($args['ip'])) {
200 188
 			error_log('cpanelLicensing::extendOnetimeUpdates was passed an invalid ip');
201 189
 			return;
202 190
 		}
@@ -207,13 +195,12 @@  discard block
 block discarded – undo
207 195
 	* @param $args
208 196
 	* @return array|mixed|void
209 197
 	*/
210
-	public function changeip($args)
211
-	{
212
-		if (!array_key_exists('oldip', $args) || !array_key_exists('newip', $args)) {
198
+	public function changeip($args) {
199
+		if (!array_key_exists('oldip', $args) || !array_key_exists('newip', $args)) {
213 200
 			error_log('cpanelLicensing::changeip requires that oldip and newip elements exist in the array passed to it');
214 201
 			return;
215 202
 		}
216
-		if (!$this->validateIP($args['newip'])) {
203
+		if (!$this->validateIP($args['newip'])) {
217 204
 			error_log('the newip passed to cpanelLicensing::changeip was invalid');
218 205
 			return;
219 206
 		}
@@ -224,21 +211,20 @@  discard block
 block discarded – undo
224 211
 	* @param $args
225 212
 	* @return array|mixed|void
226 213
 	*/
227
-	public function requestTransfer($args)
228
-	{
229
-		if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packagegroup', $args)) {
214
+	public function requestTransfer($args) {
215
+		if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packagegroup', $args)) {
230 216
 			error_log('cpanelLicensing::requestTransfer requires that ip, groupid and packageid elements exist in the array passed to it');
231 217
 			return;
232 218
 		}
233
-		if (!$this->validateID($args['groupid'])) {
219
+		if (!$this->validateID($args['groupid'])) {
234 220
 			error_log('The groupid passed to cpanelLicensing::requestTransfer is invalid');
235 221
 			return;
236 222
 		}
237
-		if (!$this->validateID($args['packageid'])) {
223
+		if (!$this->validateID($args['packageid'])) {
238 224
 			error_log('The package id passed to cpanelLicensing::requestTransfer is invalid');
239 225
 			return;
240 226
 		}
241
-		if (!$this->validateIP($args['ip'])) {
227
+		if (!$this->validateIP($args['ip'])) {
242 228
 			error_log('the ip passed to cpanelLicensing::requestTransfer was invalid');
243 229
 			return;
244 230
 		}
@@ -249,21 +235,20 @@  discard block
 block discarded – undo
249 235
 	* @param $args
250 236
 	* @return array|mixed|void
251 237
 	*/
252
-	public function activateLicense($args)
253
-	{
254
-		if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packageid', $args)) {
238
+	public function activateLicense($args) {
239
+		if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packageid', $args)) {
255 240
 			error_log('cpanelLicensing::activateLicense requires that ip, groupid and packageid elements exist in the array passed to it');
256 241
 			return;
257 242
 		}
258
-		if (!$this->validateID($args['groupid'])) {
243
+		if (!$this->validateID($args['groupid'])) {
259 244
 			error_log('cpanelLicensing::acivateLicense was passed an invalid groupid');
260 245
 			return;
261 246
 		}
262
-		if (!$this->validateIP($args['ip'])) {
247
+		if (!$this->validateIP($args['ip'])) {
263 248
 			error_log('cpanelLicensing::activateLicense was passed an invalid IP');
264 249
 			return;
265 250
 		}
266
-		if (!$this->validateID($args['packageid'])) {
251
+		if (!$this->validateID($args['packageid'])) {
267 252
 			error_log('cpanelLicensing::activateLicense was passed an invalid packageid');
268 253
 			return;
269 254
 		}
@@ -275,9 +260,8 @@  discard block
 block discarded – undo
275 260
 	* @param $args
276 261
 	* @return array|mixed|void
277 262
 	*/
278
-	public function addPickupPass($args)
279
-	{
280
-		if (!array_key_exists('pickup', $args)) {
263
+	public function addPickupPass($args) {
264
+		if (!array_key_exists('pickup', $args)) {
281 265
 			error_log('cPanelLicensing::addPickupPass requires a pickup param');
282 266
 			return;
283 267
 		}
@@ -288,22 +272,21 @@  discard block
 block discarded – undo
288 272
 	* @param $args
289 273
 	* @return array|mixed|void
290 274
 	*/
291
-	public function registerAuth($args)
292
-	{
293
-		if (!array_key_exists('user', $args)) {
275
+	public function registerAuth($args) {
276
+		if (!array_key_exists('user', $args)) {
294 277
 			error_log('cPanelLicensing::registerAuth requires a user param');
295 278
 			return;
296 279
 		}
297
-		if (!array_key_exists('pickup', $args)) {
280
+		if (!array_key_exists('pickup', $args)) {
298 281
 			error_log('cPanelLicensing::registerAuth requires a pickup param');
299 282
 			return;
300 283
 		}
301
-		if (!array_key_exists('service', $args)) {
284
+		if (!array_key_exists('service', $args)) {
302 285
 			error_log('cPanelLicensing::registerAuth requires a service param');
303 286
 			return;
304 287
 		}
305 288
 		$response = $this->get('XMLregisterAuth.cgi', $args);
306
-		if ($this->format == 'simplexml') {
289
+		if ($this->format == 'simplexml') {
307 290
 			$this->setCredentials($args['user'], $response['key']);
308 291
 		}
309 292
 		return $response;
@@ -314,8 +297,7 @@  discard block
 block discarded – undo
314 297
 	*
315 298
 	* @return array|mixed|void
316 299
 	*/
317
-	public function fetchGroups()
318
-	{
300
+	public function fetchGroups() {
319 301
 		return $this->get('XMLgroupInfo.cgi');
320 302
 	}
321 303
 
@@ -325,13 +307,12 @@  discard block
 block discarded – undo
325 307
 	* @param array $args
326 308
 	* @return array|mixed|void
327 309
 	*/
328
-	public function fetchLicenseRiskData($args = [])
329
-	{
330
-		if (!array_key_exists('ip', $args)) {
310
+	public function fetchLicenseRiskData($args = []) {
311
+		if (!array_key_exists('ip', $args)) {
331 312
 			error_log('cpanelLicensing::fetchLicenseRiskData requires that ip exists as an element in the array is passed to it');
332 313
 			return;
333 314
 		}
334
-		if (!$this->validateIP($args['ip'])) {
315
+		if (!$this->validateIP($args['ip'])) {
335 316
 			error_log('cpanelLicensing::fetchLicenseRiskData was passed an invalid ip');
336 317
 			return;
337 318
 		}
@@ -344,14 +325,13 @@  discard block
 block discarded – undo
344 325
 	* @param array $args optional array of arguments
345 326
 	* @return array|mixed|void
346 327
 	*/
347
-	public function fetchLicenseRaw($args = [])
348
-	{
328
+	public function fetchLicenseRaw($args = []) {
349 329
 		$args = array_merge(['all' => 1], $args);
350
-		if (!array_key_exists('ip', $args)) {
330
+		if (!array_key_exists('ip', $args)) {
351 331
 			error_log('cpanelLicesning::fetchLicenseRaw requires that ip exists as an element in the array is passed to it');
352 332
 			return;
353 333
 		}
354
-		if (!$this->validateIP($args['ip'])) {
334
+		if (!$this->validateIP($args['ip'])) {
355 335
 			error_log('cpanelLicensing::fetchLicenseRaw was passed an invalid ip');
356 336
 			return;
357 337
 		}
@@ -364,14 +344,13 @@  discard block
 block discarded – undo
364 344
 	* @param array $args optional array of arguments
365 345
 	* @return array|mixed|void
366 346
 	*/
367
-	public function fetchLicenseId($args = [])
368
-	{
347
+	public function fetchLicenseId($args = []) {
369 348
 		$args = array_merge(['all' => 1], $args);
370
-		if (!array_key_exists('ip', $args)) {
349
+		if (!array_key_exists('ip', $args)) {
371 350
 			error_log('cpanelLicensing::getLicenseId requires that an IP is passed to it');
372 351
 			return;
373 352
 		}
374
-		if (!$this->validateIP($args['ip'])) {
353
+		if (!$this->validateIP($args['ip'])) {
375 354
 			error_log('cpanelLicensing::fetchLicenseId was passed an invalid ip');
376 355
 			return;
377 356
 		}
@@ -381,8 +360,7 @@  discard block
 block discarded – undo
381 360
 	/**
382 361
 	* @return array|mixed|void
383 362
 	*/
384
-	public function fetchPackages($expand = false)
385
-	{
363
+	public function fetchPackages($expand = false) {
386 364
 		return $this->get('XMLpackageInfo.cgi', ($expand === true ? ['expand' => 1] : []));
387 365
 	}
388 366
 
@@ -392,8 +370,7 @@  discard block
 block discarded – undo
392 370
 	* @param array $args optional arguments
393 371
 	* @return array|mixed|void
394 372
 	*/
395
-	public function fetchLicenses($args = [])
396
-	{
373
+	public function fetchLicenses($args = []) {
397 374
 		return $this->get('XMLlicenseInfo.cgi');
398 375
 	}
399 376
 
@@ -401,8 +378,7 @@  discard block
 block discarded – undo
401 378
 	* return sa list of expired licenses
402 379
 	* @return array|mixed|void
403 380
 	*/
404
-	public function fetchExpiredLicenses()
405
-	{
381
+	public function fetchExpiredLicenses() {
406 382
 		return $this->fetchLicenses(['expired' => '1']);
407 383
 	}
408 384
 
@@ -411,20 +387,19 @@  discard block
 block discarded – undo
411 387
 	* @param $xmlObj
412 388
 	* @return string|void
413 389
 	*/
414
-	public function findKey($search, $xmlObj)
415
-	{
390
+	public function findKey($search, $xmlObj) {
416 391
 		$xmlObj = (array) $xmlObj;
417
-		if (array_key_exists('packages', $xmlObj)) {
392
+		if (array_key_exists('packages', $xmlObj)) {
418 393
 			$type = 'packages';
419
-		} elseif (array_key_exists('groups', $xmlObj)) {
394
+		} elseif (array_key_exists('groups', $xmlObj)) {
420 395
 			$type = 'groups';
421
-		} else {
396
+		} else {
422 397
 			error_log('cPanelLicensing::findKey with an object that is not groups or packages');
423 398
 			return;
424 399
 		}
425
-		foreach ((array) $xmlObj[$type] as $element) {
426
-			foreach ((array) $element as $key => $value) {
427
-				if ((string) $value == $search) {
400
+		foreach ((array) $xmlObj[$type] as $element) {
401
+			foreach ((array) $element as $key => $value) {
402
+				if ((string) $value == $search) {
428 403
 					return (string) $key;
429 404
 				}
430 405
 			}
Please login to merge, or discard this patch.