Passed
Push — master ( 6ad54f...d625d8 )
by Roeland
12:14 queued 16s
created
lib/private/Files/Storage/DAV.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				if (is_string($params['secure'])) {
105 105
 					$this->secure = ($params['secure'] === 'true');
106 106
 				} else {
107
-					$this->secure = (bool)$params['secure'];
107
+					$this->secure = (bool) $params['secure'];
108 108
 				}
109 109
 			} else {
110 110
 				$this->secure = false;
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 				}
122 122
 			}
123 123
 			$this->root = $params['root'] ?? '/';
124
-			$this->root = '/' . ltrim($this->root, '/');
125
-			$this->root = rtrim($this->root, '/') . '/';
124
+			$this->root = '/'.ltrim($this->root, '/');
125
+			$this->root = rtrim($this->root, '/').'/';
126 126
 		} else {
127 127
 			throw new \Exception('Invalid webdav storage configuration');
128 128
 		}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 	/** {@inheritdoc} */
166 166
 	public function getId() {
167
-		return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
167
+		return 'webdav::'.$this->user.'@'.$this->host.'/'.$this->root;
168 168
 	}
169 169
 
170 170
 	/** {@inheritdoc} */
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		if ($this->secure) {
174 174
 			$baseUri .= 's';
175 175
 		}
176
-		$baseUri .= '://' . $this->host . $this->root;
176
+		$baseUri .= '://'.$this->host.$this->root;
177 177
 		return $baseUri;
178 178
 	}
179 179
 
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 		$path = $this->cleanPath($path);
195 195
 		// FIXME: some WebDAV impl return 403 when trying to DELETE
196 196
 		// a non-empty folder
197
-		$result = $this->simpleResponse('DELETE', $path . '/', null, 204);
198
-		$this->statCache->clear($path . '/');
197
+		$result = $this->simpleResponse('DELETE', $path.'/', null, 204);
198
+		$this->statCache->clear($path.'/');
199 199
 		$this->statCache->remove($path);
200 200
 		return $result;
201 201
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 				$this->statCache->set($path, $response);
271 271
 			} catch (ClientHttpException $e) {
272 272
 				if ($e->getHttpStatus() === 404 || $e->getHttpStatus() === 405) {
273
-					$this->statCache->clear($path . '/');
273
+					$this->statCache->clear($path.'/');
274 274
 					$this->statCache->set($path, false);
275 275
 					return false;
276 276
 				}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		$this->init();
328 328
 		$path = $this->cleanPath($path);
329 329
 		$result = $this->simpleResponse('DELETE', $path, null, 204);
330
-		$this->statCache->clear($path . '/');
330
+		$this->statCache->clear($path.'/');
331 331
 		$this->statCache->remove($path);
332 332
 		return $result;
333 333
 	}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				try {
343 343
 					$response = $this->httpClientService
344 344
 						->newClient()
345
-						->get($this->createBaseUri() . $this->encodePath($path), [
345
+						->get($this->createBaseUri().$this->encodePath($path), [
346 346
 							'auth' => [$this->user, $this->password],
347 347
 							'stream' => true
348 348
 						]);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					if ($response->getStatusCode() === Http::STATUS_LOCKED) {
360 360
 						throw new \OCP\Lock\LockedException($path);
361 361
 					} else {
362
-						Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR);
362
+						Util::writeLog("webdav client", 'Guzzle get returned status code '.$response->getStatusCode(), ILogger::ERROR);
363 363
 					}
364 364
 				}
365 365
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 					$tmpFile = $tempManager->getTemporaryFile($ext);
400 400
 				}
401 401
 				$handle = fopen($tmpFile, $mode);
402
-				return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
402
+				return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) {
403 403
 					$this->writeBack($tmpFile, $path);
404 404
 				});
405 405
 		}
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 				return FileInfo::SPACE_UNKNOWN;
425 425
 			}
426 426
 			if (isset($response['{DAV:}quota-available-bytes'])) {
427
-				return (int)$response['{DAV:}quota-available-bytes'];
427
+				return (int) $response['{DAV:}quota-available-bytes'];
428 428
 			} else {
429 429
 				return FileInfo::SPACE_UNKNOWN;
430 430
 			}
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 
501 501
 		$this->httpClientService
502 502
 			->newClient()
503
-			->put($this->createBaseUri() . $this->encodePath($target), [
503
+			->put($this->createBaseUri().$this->encodePath($target), [
504 504
 				'body' => $source,
505 505
 				'auth' => [$this->user, $this->password]
506 506
 			]);
@@ -517,18 +517,18 @@  discard block
 block discarded – undo
517 517
 			// overwrite directory ?
518 518
 			if ($this->is_dir($path2)) {
519 519
 				// needs trailing slash in destination
520
-				$path2 = rtrim($path2, '/') . '/';
520
+				$path2 = rtrim($path2, '/').'/';
521 521
 			}
522 522
 			$this->client->request(
523 523
 				'MOVE',
524 524
 				$this->encodePath($path1),
525 525
 				null,
526 526
 				[
527
-					'Destination' => $this->createBaseUri() . $this->encodePath($path2),
527
+					'Destination' => $this->createBaseUri().$this->encodePath($path2),
528 528
 				]
529 529
 			);
530
-			$this->statCache->clear($path1 . '/');
531
-			$this->statCache->clear($path2 . '/');
530
+			$this->statCache->clear($path1.'/');
531
+			$this->statCache->clear($path2.'/');
532 532
 			$this->statCache->set($path1, false);
533 533
 			$this->statCache->set($path2, true);
534 534
 			$this->removeCachedFile($path1);
@@ -549,17 +549,17 @@  discard block
 block discarded – undo
549 549
 			// overwrite directory ?
550 550
 			if ($this->is_dir($path2)) {
551 551
 				// needs trailing slash in destination
552
-				$path2 = rtrim($path2, '/') . '/';
552
+				$path2 = rtrim($path2, '/').'/';
553 553
 			}
554 554
 			$this->client->request(
555 555
 				'COPY',
556 556
 				$this->encodePath($path1),
557 557
 				null,
558 558
 				[
559
-					'Destination' => $this->createBaseUri() . $this->encodePath($path2),
559
+					'Destination' => $this->createBaseUri().$this->encodePath($path2),
560 560
 				]
561 561
 			);
562
-			$this->statCache->clear($path2 . '/');
562
+			$this->statCache->clear($path2.'/');
563 563
 			$this->statCache->set($path2, true);
564 564
 			$this->removeCachedFile($path2);
565 565
 			return true;
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 			}
579 579
 			return [
580 580
 				'mtime' => strtotime($response['{DAV:}getlastmodified']),
581
-				'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
581
+				'size' => (int) isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
582 582
 			];
583 583
 		} catch (\Exception $e) {
584 584
 			$this->convertException($e, $path);
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 			return $response['statusCode'] == $expected;
661 661
 		} catch (ClientHttpException $e) {
662 662
 			if ($e->getHttpStatus() === 404 && $method === 'DELETE') {
663
-				$this->statCache->clear($path . '/');
663
+				$this->statCache->clear($path.'/');
664 664
 				$this->statCache->set($path, false);
665 665
 				return false;
666 666
 			}
@@ -681,22 +681,22 @@  discard block
 block discarded – undo
681 681
 
682 682
 	/** {@inheritdoc} */
683 683
 	public function isUpdatable($path) {
684
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
684
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
685 685
 	}
686 686
 
687 687
 	/** {@inheritdoc} */
688 688
 	public function isCreatable($path) {
689
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE);
689
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_CREATE);
690 690
 	}
691 691
 
692 692
 	/** {@inheritdoc} */
693 693
 	public function isSharable($path) {
694
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
694
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_SHARE);
695 695
 	}
696 696
 
697 697
 	/** {@inheritdoc} */
698 698
 	public function isDeletable($path) {
699
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE);
699
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_DELETE);
700 700
 	}
701 701
 
702 702
 	/** {@inheritdoc} */
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 				if (!empty($etag) && $cachedData['etag'] !== $etag) {
790 790
 					return true;
791 791
 				} else if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) {
792
-					$sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions'];
792
+					$sharePermissions = (int) $response['{http://open-collaboration-services.org/ns}share-permissions'];
793 793
 					return $sharePermissions !== $cachedData['permissions'];
794 794
 				} else if (isset($response['{http://owncloud.org/ns}permissions'])) {
795 795
 					$permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 			if ($e->getHttpStatus() === 405) {
806 806
 				if ($path === '') {
807 807
 					// if root is gone it means the storage is not available
808
-					throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
808
+					throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
809 809
 				}
810 810
 				return false;
811 811
 			}
@@ -840,22 +840,22 @@  discard block
 block discarded – undo
840 840
 			}
841 841
 			if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) {
842 842
 				// either password was changed or was invalid all along
843
-				throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage());
843
+				throw new StorageInvalidException(get_class($e).': '.$e->getMessage());
844 844
 			} else if ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) {
845 845
 				// ignore exception for MethodNotAllowed, false will be returned
846 846
 				return;
847
-			} else if ($e->getHttpStatus() === Http::STATUS_FORBIDDEN){
847
+			} else if ($e->getHttpStatus() === Http::STATUS_FORBIDDEN) {
848 848
 				// The operation is forbidden. Fail somewhat gracefully
849
-				throw new ForbiddenException(get_class($e) . ':' . $e->getMessage());
849
+				throw new ForbiddenException(get_class($e).':'.$e->getMessage());
850 850
 			}
851
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
851
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
852 852
 		} else if ($e instanceof ClientException) {
853 853
 			// connection timeout or refused, server could be temporarily down
854
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
854
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
855 855
 		} else if ($e instanceof \InvalidArgumentException) {
856 856
 			// parse error because the server returned HTML instead of XML,
857 857
 			// possibly temporarily down
858
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
858
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
859 859
 		} else if (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) {
860 860
 			// rethrow
861 861
 			throw $e;
Please login to merge, or discard this patch.