Passed
Push — develop ( 3e7098...172c78 )
by Jens
02:50
created
cloudcontrol/library/storage/JsonStorage.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		 */
34 34
 		private function config()
35 35
 		{
36
-			$storagePath = __DIR__ . $this->storagePath;
36
+			$storagePath = __DIR__.$this->storagePath;
37 37
 			if (realpath($storagePath) !== false) {
38 38
 				$jsonString = file_get_contents($storagePath);
39 39
 				$this->repository = json_decode($jsonString);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		 */
190 190
 		public function getDocumentBySlug($slug)
191 191
 		{
192
-			$documentContainer = $this->getDocumentContainerByPath('/' . $slug);
192
+			$documentContainer = $this->getDocumentContainerByPath('/'.$slug);
193 193
 			$indices = $documentContainer['indices'];
194 194
 
195 195
 			if ($indices === null) {
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				// Check for duplicates
235 235
 				foreach ($this->repository->documents as $index => $document) {
236 236
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') {
237
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
237
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
238 238
 					}
239 239
 				}
240 240
 				$this->repository->documents[end($indices)] = $documentFolderObject;
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 				// Check for duplicates
243 243
 				foreach ($previousFolder->content as $index => $document) {
244 244
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') {
245
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
245
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
246 246
 					}
247 247
 				}
248
-				$previousFolder->content[end($indices)] = $documentFolderObject ;
248
+				$previousFolder->content[end($indices)] = $documentFolderObject;
249 249
 			}
250 250
 
251 251
 			$this->save();
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				foreach ($this->repository->documents as $document) {
260 260
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'document') {
261 261
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
262
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
262
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
263 263
 					}
264 264
 				}
265 265
 				$this->repository->documents[] = $documentFolderObject;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 					foreach ($containerFolder->content as $document) {
271 271
 						if ($document->slug == $documentFolderObject->slug && $document->type == 'document') {
272 272
 							// TODO make it so it doesnt throw an exception, but instead shows a warning
273
-							throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
273
+							throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
274 274
 						}
275 275
 					}
276 276
 				}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 				foreach ($this->repository->documents as $document) {
386 386
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') {
387 387
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
388
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
388
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
389 389
 					}
390 390
 				}
391 391
 				$this->repository->documents[] = $documentFolderObject;
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 				foreach ($containerFolder->content as $document) {
407 407
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') {
408 408
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
409
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
409
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
410 410
 					}
411 411
 				}
412 412
 				$folder->content[] = $documentFolderObject;
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 		 */
459 459
 		public function getDocumentFolderBySlug($slug)
460 460
 		{
461
-			$documentContainer = $this->getDocumentContainerByPath('/' . $slug);
461
+			$documentContainer = $this->getDocumentContainerByPath('/'.$slug);
462 462
 			$indices = $documentContainer['indices'];
463 463
 
464 464
 			$folder = $this->repository->documents;
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 				// Check for duplicates
503 503
 				foreach ($this->repository->documents as $index => $document) {
504 504
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') {
505
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
505
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
506 506
 					}
507 507
 				}
508 508
 				$this->repository->documents[end($indices)] = $documentFolderObject;
@@ -510,10 +510,10 @@  discard block
 block discarded – undo
510 510
 				// Check for duplicates
511 511
 				foreach ($previousFolder->content as $index => $document) {
512 512
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') {
513
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
513
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
514 514
 					}
515 515
 				}
516
-				$previousFolder->content[end($indices)] = $documentFolderObject ;
516
+				$previousFolder->content[end($indices)] = $documentFolderObject;
517 517
 			}
518 518
 
519 519
 			$this->save();
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 					'previousDocument' => $previousDocument
584 584
 				);
585 585
 			} else {
586
-				throw new \Exception('Invalid path: ' . $path);
586
+				throw new \Exception('Invalid path: '.$path);
587 587
 			}
588 588
 		}
589 589
 
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 
769 769
 		public function addImage($postValues)
770 770
 		{
771
-			$destinationPath = realpath(__DIR__ . '/../../www/images/');
771
+			$destinationPath = realpath(__DIR__.'/../../www/images/');
772 772
 
773 773
 			$filename = $this->validateFilename($postValues['name'], $destinationPath);
774
-			$destination = $destinationPath . '/' . $filename;
774
+			$destination = $destinationPath.'/'.$filename;
775 775
 
776 776
 			if ($postValues['error'] != '0') {
777
-				throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
777
+				throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
778 778
 			}
779 779
 
780 780
 			if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -796,14 +796,14 @@  discard block
 block discarded – undo
796 796
 
797 797
 		public function deleteImageByName($filename)
798 798
 		{
799
-			$destinationPath = realpath(__DIR__ . '/../../www/images/');
799
+			$destinationPath = realpath(__DIR__.'/../../www/images/');
800 800
 
801 801
 			$images = $this->getImages();
802 802
 
803 803
 			foreach ($images as $key => $image) {
804 804
 				if ($image->file == $filename) {
805 805
 					foreach ($image->set as $imageSetFilename) {
806
-						$destination = $destinationPath . '/' . $imageSetFilename;
806
+						$destination = $destinationPath.'/'.$imageSetFilename;
807 807
 						if (file_exists($destination)) {
808 808
 							unlink($destination);
809 809
 						} else {
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 		 */
846 846
 		public function getFiles()
847 847
 		{
848
-			$files =  $this->repository->files;
848
+			$files = $this->repository->files;
849 849
 			usort($files, array($this, 'compareFiles'));
850 850
 			return $files;
851 851
 		}
@@ -857,13 +857,13 @@  discard block
 block discarded – undo
857 857
 
858 858
 		public function addFile($postValues)
859 859
 		{
860
-			$destinationPath = realpath(__DIR__ . '/../../www/files/');
860
+			$destinationPath = realpath(__DIR__.'/../../www/files/');
861 861
 
862 862
 			$filename = $this->validateFilename($postValues['name'], $destinationPath);
863
-			$destination = $destinationPath . '/' . $filename;
863
+			$destination = $destinationPath.'/'.$filename;
864 864
 
865 865
 			if ($postValues['error'] != '0') {
866
-				throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
866
+				throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
867 867
 			}
868 868
 
869 869
 			if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -887,23 +887,23 @@  discard block
 block discarded – undo
887 887
 				array_pop($fileParts);
888 888
 				$fileNameWithoutExtension = implode('-', $fileParts);
889 889
 				$fileNameWithoutExtension = slugify($fileNameWithoutExtension);
890
-				$filename = $fileNameWithoutExtension . '.' . $extension;
890
+				$filename = $fileNameWithoutExtension.'.'.$extension;
891 891
 			} else {
892 892
 				$filename = slugify($filename);
893 893
 			}
894 894
 
895
-			if (file_exists($path . '/' . $filename)) {
895
+			if (file_exists($path.'/'.$filename)) {
896 896
 				$fileParts = explode('.', $filename);
897 897
 				if (count($fileParts) > 1) {
898 898
 					$extension = end($fileParts);
899 899
 					array_pop($fileParts);
900 900
 					$fileNameWithoutExtension = implode('-', $fileParts);
901 901
 					$fileNameWithoutExtension .= '-copy';
902
-					$filename = $fileNameWithoutExtension . '.' . $extension;
902
+					$filename = $fileNameWithoutExtension.'.'.$extension;
903 903
 				} else {
904 904
 					$filename .= '-copy';
905 905
 				}
906
-				return $this->validateFilename($filename,$path);
906
+				return $this->validateFilename($filename, $path);
907 907
 			}
908 908
 			return $filename;
909 909
 		}
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
          */
930 930
 		public function deleteFileByName($filename)
931 931
 		{
932
-			$destinationPath = realpath(__DIR__ . '/../../www/files/');
933
-			$destination = $destinationPath . '/' . $filename;
932
+			$destinationPath = realpath(__DIR__.'/../../www/files/');
933
+			$destination = $destinationPath.'/'.$filename;
934 934
 
935 935
 			if (file_exists($destination)) {
936 936
 				$files = $this->getFiles();
@@ -1226,11 +1226,11 @@  discard block
 block discarded – undo
1226 1226
 		 * @throws \Exception
1227 1227
 		 */
1228 1228
 		private function save() {
1229
-			$storagePath = __DIR__ . $this->storagePath;
1229
+			$storagePath = __DIR__.$this->storagePath;
1230 1230
 			if (realpath($storagePath) !== false) {
1231 1231
 				file_put_contents($storagePath, json_encode($this->repository));
1232 1232
 			} else {
1233
-				throw new \Exception('Couldnt find storagePath ' . $storagePath);
1233
+				throw new \Exception('Couldnt find storagePath '.$storagePath);
1234 1234
 			}
1235 1235
 		}
1236 1236
 
Please login to merge, or discard this patch.
cloudcontrol/library/components/DocumentComponent.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@
 block discarded – undo
20 20
 				if (isset($this->parameters['document'])) {
21 21
 					$this->parameters['document'] = $storage->getDocumentBySlug($this->parameters['document']);
22 22
 				} else {
23
-					throw new \Exception('When not using a regex, you need to set the parameter `document` with the path to the document in this sitemap item: ' . $this->matchedSitemapItem->title);
23
+					throw new \Exception('When not using a regex, you need to set the parameter `document` with the path to the document in this sitemap item: '.$this->matchedSitemapItem->title);
24 24
 				}
25 25
 			} else {
26 26
 				$relativeDocumentUri = current($this->matchedSitemapItem->matches[1]);
27 27
 				if (isset($this->parameters['folder'])) {
28 28
 					if (substr($this->parameters['folder'], -1) !== '/') {
29
-						$this->parameters['folder'] = $this->parameters['folder'] . '/';
29
+						$this->parameters['folder'] = $this->parameters['folder'].'/';
30 30
 					}
31
-					$relativeDocumentUri = $this->parameters['folder'] . $relativeDocumentUri;
31
+					$relativeDocumentUri = $this->parameters['folder'].$relativeDocumentUri;
32 32
 				}
33 33
 
34 34
 				$document = $storage->getDocumentBySlug($relativeDocumentUri);
Please login to merge, or discard this patch.