Test Failed
Push — master ( 068ed3...2d875e )
by Joe
03:42
created
src/Fantastico.php 2 patches
Braces   +16 added lines, -32 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @package Detain\Fantastico
20 20
  */
21
-class Fantastico
22
-{
21
+class Fantastico {
23 22
 
24 23
 	/**
25 24
 	 * All fantastico license types
@@ -81,8 +80,7 @@  discard block
 block discarded – undo
81 80
 	 * @param string $username username to connect to fantastico api with
82 81
 	 * @param string $password password to connect to fantastico api with
83 82
 	 */
84
-	public function __construct($username, $password)
85
-	{
83
+	public function __construct($username, $password) {
86 84
 		$this->cache = [];
87 85
 		$this->soapClient = null;
88 86
 		$this->apiUsername = $username;
@@ -95,8 +93,7 @@  discard block
 block discarded – undo
95 93
 	 *
96 94
 	 * @return void
97 95
 	 */
98
-	public function connect()
99
-	{
96
+	public function connect() {
100 97
 		$nusoap = false;
101 98
 		if (null === $this->soapClient) {
102 99
 			ini_set('soap.wsdl_cache_enabled', '0');
@@ -123,8 +120,7 @@  discard block
 block discarded – undo
123 120
 	 *
124 121
 	 * @return array returns an array of possible license types and descriptions of them
125 122
 	 */
126
-	public function getIpTypes()
127
-	{
123
+	public function getIpTypes() {
128 124
 		return $this->types;
129 125
 	}
130 126
 
@@ -136,8 +132,7 @@  discard block
 block discarded – undo
136 132
 	 * @param integer $type
137 133
 	 * @return bool whether or not its a valid fantastico license type
138 134
 	 */
139
-	public function isType($type)
140
-	{
135
+	public function isType($type) {
141 136
 		return array_key_exists($type, $this->types);
142 137
 	}
143 138
 
@@ -147,8 +142,7 @@  discard block
 block discarded – undo
147 142
 	 *
148 143
 	 * @return string the login hash
149 144
 	 */
150
-	private function getHash()
151
-	{
145
+	private function getHash() {
152 146
 		return md5($this->apiUsername.$this->apiPassword);
153 147
 	}
154 148
 
@@ -167,8 +161,7 @@  discard block
 block discarded – undo
167 161
 	 * @param integer $type one of the possible fantastico license types, defaults to {@link self::ALL_TYPES}
168 162
 	 * @return FALSE|array returns FALSE on error or an array of license details
169 163
 	 */
170
-	public function getIpList($type = self::ALL_TYPES)
171
-	{
164
+	public function getIpList($type = self::ALL_TYPES) {
172 165
 		if (isset($this->cache['getIpList_'.$type])) {
173 166
 			return $this->cache['getIpList_'.$type];
174 167
 		}
@@ -222,8 +215,7 @@  discard block
 block discarded – undo
222 215
 	 * @param integer $type one of the possible fantastico license types, defaults to {@link self::ALL_TYPES}
223 216
 	 * @return FALSE|array returns FALSE on error or an array of license details
224 217
 	 */
225
-	public function getIpListDetailed($type = self::ALL_TYPES)
226
-	{
218
+	public function getIpListDetailed($type = self::ALL_TYPES) {
227 219
 		if (!$this->isType($type)) {
228 220
 			return false;
229 221
 		}
@@ -272,8 +264,7 @@  discard block
 block discarded – undo
272 264
 	 * @param string $ipAddress IP Address to validate
273 265
 	 * @return bool whether or not the ip was validated
274 266
 	 */
275
-	public function validIp($ipAddress)
276
-	{
267
+	public function validIp($ipAddress) {
277 268
 		return ip2long($ipAddress) !== false;
278 269
 	}
279 270
 
@@ -302,8 +293,7 @@  discard block
 block discarded – undo
302 293
 	 * @param string $ipAddress ip address to get details for
303 294
 	 * @return mixed returns FALSE on invalid IP, or an array of the details.
304 295
 	 */
305
-	public function getIpDetails($ipAddress)
306
-	{
296
+	public function getIpDetails($ipAddress) {
307 297
 		if (!$this->validIp($ipAddress)) {
308 298
 			return ['faultcode' => 1, 'fault ' => 'Invalid IP Address '.$ipAddress];
309 299
 		}
@@ -382,8 +372,7 @@  discard block
 block discarded – undo
382 372
 	 * @param mixed $newip new ip address to change i tot
383 373
 	 * @return array returns an array of ip and newip or a fault and faultcode
384 374
 	 */
385
-	public function editIp($ipAddress, $newip)
386
-	{
375
+	public function editIp($ipAddress, $newip) {
387 376
 		if (!$this->validIp($ipAddress)) {
388 377
 			$response = ['faultcode' => 1, 'fault' => 'Invalid IP Address '.$ipAddress];
389 378
 		} elseif (!$this->validIp($newip)) {
@@ -463,8 +452,7 @@  discard block
 block discarded – undo
463 452
 	 * @param integer $type license type
464 453
 	 * @return array response array containing a faultcode and fault, or ip and id on success
465 454
 	 */
466
-	public function addIp($ipAddress, $type)
467
-	{
455
+	public function addIp($ipAddress, $type) {
468 456
 		if (!$this->validIp($ipAddress)) {
469 457
 			$response = ['faultcode' => 1, 'fault' => 'Invalid IP Address '.$ipAddress];
470 458
 		} else {
@@ -485,8 +473,7 @@  discard block
 block discarded – undo
485 473
 	 * @param $ipAddress
486 474
 	 * @return array|mixed
487 475
 	 */
488
-	private function soapIpFunction($function, $ipAddress)
489
-	{
476
+	private function soapIpFunction($function, $ipAddress) {
490 477
 		if (!$this->validIp($ipAddress)) {
491 478
 			return ['faultcode' => 1, 'fault ' => 'Invalid IP Address '.$ipAddress];
492 479
 		}
@@ -519,8 +506,7 @@  discard block
 block discarded – undo
519 506
 	 * @param mixed $ipAddress
520 507
 	 * @return void
521 508
 	 */
522
-	public function deactivateIp($ipAddress)
523
-	{
509
+	public function deactivateIp($ipAddress) {
524 510
 		return $this->soapIpFunction('deactivateIp', $ipAddress);
525 511
 	}
526 512
 
@@ -546,8 +532,7 @@  discard block
 block discarded – undo
546 532
 	 * @param mixed $ipAddress
547 533
 	 * @return void
548 534
 	 */
549
-	public function reactivateIp($ipAddress)
550
-	{
535
+	public function reactivateIp($ipAddress) {
551 536
 		return $this->soapIpFunction('reactivateIp', $ipAddress);
552 537
 	}
553 538
 
@@ -574,8 +559,7 @@  discard block
 block discarded – undo
574 559
 	 * @param mixed $ipAddress
575 560
 	 * @return void
576 561
 	 */
577
-	public function deleteIp($ipAddress)
578
-	{
562
+	public function deleteIp($ipAddress) {
579 563
 		return $this->soapIpFunction('deleteIp', $ipAddress);
580 564
 	}
581 565
 }
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 			return false;
177 177
 		}
178 178
 		$this->connect();
179
-        \StatisticClient::tick('Fantastico', 'getIpList');
179
+		\StatisticClient::tick('Fantastico', 'getIpList');
180 180
 		$this->cache['getIpList_'.$type] = json_decode($this->soapClient->getIpList($this->getHash(), $type), true);
181
-        if ($this->cache['getIpList_'.$type] === false)
182
-            \StatisticClient::report('Fantastico', 'getIpList', false, 1, 'Soap Client Error', STATISTICS_SERVER);
183
-        else
184
-            \StatisticClient::report('Fantastico', 'getIpList', true, 0, '', STATISTICS_SERVER);        
181
+		if ($this->cache['getIpList_'.$type] === false)
182
+			\StatisticClient::report('Fantastico', 'getIpList', false, 1, 'Soap Client Error', STATISTICS_SERVER);
183
+		else
184
+			\StatisticClient::report('Fantastico', 'getIpList', true, 0, '', STATISTICS_SERVER);        
185 185
 		myadmin_log('fantastico', 'debug', json_encode($this->cache['getIpList_'.$type]), __LINE__, __FILE__);
186 186
 		return $this->cache['getIpList_'.$type];
187 187
 	}
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 		}
238 238
 		$this->connect();
239 239
 		//try {
240
-        \StatisticClient::tick('Fantastico', 'getIpListDetailed');
240
+		\StatisticClient::tick('Fantastico', 'getIpListDetailed');
241 241
 		$response = json_decode($this->soapClient->__soapCall('getIpListDetailed', [$this->getHash(), $type]), true);
242
-        if ($response === false)
243
-            \StatisticClient::report('Fantastico', 'getIpListDetailed', false, 1, 'Soap Client Error', STATISTICS_SERVER);
244
-        else
245
-            \StatisticClient::report('Fantastico', 'getIpListDetailed', true, 0, '', STATISTICS_SERVER);        
242
+		if ($response === false)
243
+			\StatisticClient::report('Fantastico', 'getIpListDetailed', false, 1, 'Soap Client Error', STATISTICS_SERVER);
244
+		else
245
+			\StatisticClient::report('Fantastico', 'getIpListDetailed', true, 0, '', STATISTICS_SERVER);        
246 246
 		myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__);
247 247
 		//echo '<pre>';echo print_r($response, TRUE);echo '</pre>';
248 248
 		//$this->cache['getIpListDetailed_'.$type] = $this->cache['getIpListDetailed_'.$type]->Licenses;
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 			return $this->cache['getIpDetails_'.$ipAddress];
322 322
 		}
323 323
 		$this->connect();
324
-        \StatisticClient::tick('Fantastico', 'getIpDetails');
324
+		\StatisticClient::tick('Fantastico', 'getIpDetails');
325 325
 		$this->cache['getIpDetails_'.$ipAddress] = json_decode($this->soapClient->getIpDetails($this->getHash(), $ipAddress), true);
326
-        if ($this->cache['getIpDetails_'.$ipAddress] === false)
327
-            \StatisticClient::report('Fantastico', 'getIpDetails', false, 1, 'Soap Client Error', STATISTICS_SERVER);
328
-        else
329
-            \StatisticClient::report('Fantastico', 'getIpDetails', true, 0, '', STATISTICS_SERVER);        
326
+		if ($this->cache['getIpDetails_'.$ipAddress] === false)
327
+			\StatisticClient::report('Fantastico', 'getIpDetails', false, 1, 'Soap Client Error', STATISTICS_SERVER);
328
+		else
329
+			\StatisticClient::report('Fantastico', 'getIpDetails', true, 0, '', STATISTICS_SERVER);        
330 330
 		myadmin_log('fantastico', 'debug', json_encode($this->cache['getIpDetails_'.$ipAddress]), __LINE__, __FILE__);
331 331
 		return $this->cache['getIpDetails_'.$ipAddress];
332 332
 	}
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$response = ['faultcode' => 2, 'fault' => 'Invalid IP Address '.$newip];
406 406
 		} else {
407 407
 			$this->connect();
408
-            \StatisticClient::tick('Fantastico', 'editIp');
408
+			\StatisticClient::tick('Fantastico', 'editIp');
409 409
 			$response = json_decode($this->soapClient->editIp($this->getHash(), $ipAddress, $newip), true);
410
-            if ($response === false)
411
-                \StatisticClient::report('Fantastico', 'editIp', false, 1, 'Soap Client Error', STATISTICS_SERVER);
412
-            else
413
-                \StatisticClient::report('Fantastico', 'editIp', true, 0, '', STATISTICS_SERVER);        
410
+			if ($response === false)
411
+				\StatisticClient::report('Fantastico', 'editIp', false, 1, 'Soap Client Error', STATISTICS_SERVER);
412
+			else
413
+				\StatisticClient::report('Fantastico', 'editIp', true, 0, '', STATISTICS_SERVER);        
414 414
 			myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__);
415 415
 			if (isset($response['fault '])) {
416 416
 				$response['fault'] = $response['fault '];
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
 			$response = ['faultcode' => 1, 'fault' => 'Invalid IP Address '.$ipAddress];
490 490
 		} else {
491 491
 			$this->connect();
492
-            \StatisticClient::tick('Fantastico', 'addIp');
492
+			\StatisticClient::tick('Fantastico', 'addIp');
493 493
 			$response = json_decode($this->soapClient->addIp($this->getHash(), $ipAddress, $type), true);
494
-            if ($response === false)
495
-                \StatisticClient::report('Fantastico', 'addIp', false, 1, 'Soap Client Error', STATISTICS_SERVER);
496
-            else
497
-                \StatisticClient::report('Fantastico', 'addIp', true, 0, '', STATISTICS_SERVER);        
494
+			if ($response === false)
495
+				\StatisticClient::report('Fantastico', 'addIp', false, 1, 'Soap Client Error', STATISTICS_SERVER);
496
+			else
497
+				\StatisticClient::report('Fantastico', 'addIp', true, 0, '', STATISTICS_SERVER);        
498 498
 			myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__);
499 499
 			if (isset($response['fault '])) {
500 500
 				$response['fault'] = $response['fault '];
@@ -516,12 +516,12 @@  discard block
 block discarded – undo
516 516
 			return ['faultcode' => 1, 'fault ' => 'Invalid IP Address '.$ipAddress];
517 517
 		}
518 518
 		$this->connect();
519
-        \StatisticClient::tick('Fantastico', $function);
519
+		\StatisticClient::tick('Fantastico', $function);
520 520
 		$response = json_decode($this->soapClient->$function($this->getHash(), $ipAddress), true);
521
-        if ($response === false)
522
-            \StatisticClient::report('Fantastico', $function, false, 1, 'Soap Client Error', STATISTICS_SERVER);
523
-        else
524
-            \StatisticClient::report('Fantastico', $function, true, 0, '', STATISTICS_SERVER);        
521
+		if ($response === false)
522
+			\StatisticClient::report('Fantastico', $function, false, 1, 'Soap Client Error', STATISTICS_SERVER);
523
+		else
524
+			\StatisticClient::report('Fantastico', $function, true, 0, '', STATISTICS_SERVER);        
525 525
 		myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__);
526 526
 		$this->cache = [];
527 527
 		return $response;
Please login to merge, or discard this patch.