Passed
Push — develop ( 7ee7eb...278ae4 )
by Jens
02:44
created
cloudcontrol/library/cc/cc.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 		return '0 seconds';
39 39
 	}
40 40
 
41
-	$a = array( 365 * 24 * 60 * 60  =>  'year',
41
+	$a = array(365 * 24 * 60 * 60  =>  'year',
42 42
 				30 * 24 * 60 * 60  =>  'month',
43 43
 				24 * 60 * 60  =>  'day',
44 44
 				60 * 60  =>  'hour',
45 45
 				60  =>  'minute',
46 46
 				1  =>  'second'
47 47
 	);
48
-	$a_plural = array( 'year'   => 'years',
48
+	$a_plural = array('year'   => 'years',
49 49
 					   'month'  => 'months',
50 50
 					   'day'    => 'days',
51 51
 					   'hour'   => 'hours',
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		if ($d >= 1)
60 60
 		{
61 61
 			$r = round($d);
62
-			return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago';
62
+			return $r.' '.($r > 1 ? $a_plural[$str] : $str).' ago';
63 63
 		}
64 64
 	}
65 65
 	return 0;
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
  * @param string $unit
74 74
  * @return string
75 75
  */
76
-function humanFileSize($size,$unit="") {
77
-	if( (!$unit && $size >= 1<<30) || $unit == "GB")
78
-		return number_format($size/(1<<30),2)."GB";
79
-	if( (!$unit && $size >= 1<<20) || $unit == "MB")
80
-		return number_format($size/(1<<20),2)."MB";
81
-	if( (!$unit && $size >= 1<<10) || $unit == "KB")
82
-		return number_format($size/(1<<10),2)."KB";
76
+function humanFileSize($size, $unit = "") {
77
+	if ((!$unit && $size >= 1 << 30) || $unit == "GB")
78
+		return number_format($size / (1 << 30), 2)."GB";
79
+	if ((!$unit && $size >= 1 << 20) || $unit == "MB")
80
+		return number_format($size / (1 << 20), 2)."MB";
81
+	if ((!$unit && $size >= 1 << 10) || $unit == "KB")
82
+		return number_format($size / (1 << 10), 2)."KB";
83 83
 	return number_format($size)." bytes";
84 84
 }
85 85
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @return mixed|string
135 135
  */
136
-function slugify($str, $replace=array(), $delimiter='-') {
137
-	if( !empty($replace) ) {
138
-		$str = str_replace((array)$replace, ' ', $str);
136
+function slugify($str, $replace = array(), $delimiter = '-') {
137
+	if (!empty($replace)) {
138
+		$str = str_replace((array) $replace, ' ', $str);
139 139
 	}
140 140
 
141 141
 	$clean = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str);
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 {
159 159
 	$debug_backtrace = current(debug_backtrace());
160 160
 	if (PHP_SAPI == 'cli') {
161
-		echo 'Dump: ' . $debug_backtrace['file'] . ':' . $debug_backtrace['line'] . "\n";
161
+		echo 'Dump: '.$debug_backtrace['file'].':'.$debug_backtrace['line']."\n";
162 162
 		foreach (func_get_args() as $data) {
163 163
 			var_dump($data);
164 164
 		}
165 165
 	} else {
166 166
 		ob_clean();
167
-		echo '<div>Dump: ' . $debug_backtrace['file'] . ':<b>' . $debug_backtrace['line'] . "</b></div>";
167
+		echo '<div>Dump: '.$debug_backtrace['file'].':<b>'.$debug_backtrace['line']."</b></div>";
168 168
 		echo '<pre>';
169 169
 		foreach (func_get_args() as $data) {
170 170
 			echo "<code>";
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
  */
215 215
 function utf8Convert($array)
216 216
 {
217
-	array_walk_recursive($array, function(&$item, $key){
218
-		if(!mb_detect_encoding($item, 'utf-8', true)){
217
+	array_walk_recursive($array, function(&$item, $key) {
218
+		if (!mb_detect_encoding($item, 'utf-8', true)) {
219 219
 			$item = utf8_encode($item);
220 220
 		}
221 221
 	});
Please login to merge, or discard this patch.
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->storageDir;
36
+			$storagePath = __DIR__.'/../../'.$this->storageDir;
37 37
 			if (realpath($storagePath) === false) {
38 38
 				initFramework($storagePath);
39 39
 				if (Repository::create($storagePath)) {
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 					$repository->init();
42 42
 					$this->repository = $repository;
43 43
 				} else {
44
-					throw new \Exception('Could not create repository directory: ' . $storagePath);
44
+					throw new \Exception('Could not create repository directory: '.$storagePath);
45 45
 				}
46 46
 			} else {
47 47
 				$this->repository = new Repository($storagePath);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		 */
192 192
 		public function getDocumentBySlug($slug)
193 193
 		{
194
-			$documentContainer = $this->getDocumentContainerByPath('/' . $slug);
194
+			$documentContainer = $this->getDocumentContainerByPath('/'.$slug);
195 195
 			$indices = $documentContainer['indices'];
196 196
 
197 197
 			if ($indices === null) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				// Check for duplicates
237 237
 				foreach ($this->repository->documents as $index => $document) {
238 238
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') {
239
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
239
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
240 240
 					}
241 241
 				}
242 242
 				$this->repository->documents[end($indices)] = $documentFolderObject;
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 				// Check for duplicates
245 245
 				foreach ($previousFolder->content as $index => $document) {
246 246
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') {
247
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
247
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
248 248
 					}
249 249
 				}
250
-				$previousFolder->content[end($indices)] = $documentFolderObject ;
250
+				$previousFolder->content[end($indices)] = $documentFolderObject;
251 251
 			}
252 252
 
253 253
 			$this->save();
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 				foreach ($this->repository->documents as $document) {
262 262
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'document') {
263 263
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
264
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
264
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
265 265
 					}
266 266
 				}
267 267
 				$this->repository->documents[] = $documentFolderObject;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 					foreach ($containerFolder->content as $document) {
273 273
 						if ($document->slug == $documentFolderObject->slug && $document->type == 'document') {
274 274
 							// TODO make it so it doesnt throw an exception, but instead shows a warning
275
-							throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
275
+							throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
276 276
 						}
277 277
 					}
278 278
 				}
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 				foreach ($this->repository->documents as $document) {
391 391
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') {
392 392
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
393
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
393
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
394 394
 					}
395 395
 				}
396 396
 				$this->repository->documents[] = $documentFolderObject;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 				foreach ($containerFolder->content as $document) {
412 412
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') {
413 413
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
414
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
414
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
415 415
 					}
416 416
 				}
417 417
 				$folder->content[] = $documentFolderObject;
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 		 */
464 464
 		public function getDocumentFolderBySlug($slug)
465 465
 		{
466
-			$documentContainer = $this->getDocumentContainerByPath('/' . $slug);
466
+			$documentContainer = $this->getDocumentContainerByPath('/'.$slug);
467 467
 			$indices = $documentContainer['indices'];
468 468
 
469 469
 			$folder = $this->repository->documents;
470 470
 			if ($indices === null) {
471
-				throw new \Exception('Can\'t find folder with slug `' . $slug . '`');
471
+				throw new \Exception('Can\'t find folder with slug `'.$slug.'`');
472 472
 			}
473 473
 			foreach ($indices as $index) {
474 474
 				if ($folder === $this->repository->documents) {
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 				// Check for duplicates
511 511
 				foreach ($this->repository->documents 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 516
 				$this->repository->documents[end($indices)] = $documentFolderObject;
@@ -518,10 +518,10 @@  discard block
 block discarded – undo
518 518
 				// Check for duplicates
519 519
 				foreach ($previousFolder->content as $index => $document) {
520 520
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') {
521
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
521
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
522 522
 					}
523 523
 				}
524
-				$previousFolder->content[end($indices)] = $documentFolderObject ;
524
+				$previousFolder->content[end($indices)] = $documentFolderObject;
525 525
 			}
526 526
 
527 527
 			$this->save();
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 					'previousDocument' => $previousDocument
591 591
 				);
592 592
 			} else {
593
-				throw new \Exception('Invalid path: ' . $path);
593
+				throw new \Exception('Invalid path: '.$path);
594 594
 			}
595 595
 		}
596 596
 
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
 
777 777
 		public function addImage($postValues)
778 778
 		{
779
-			$destinationPath = realpath(__DIR__ . '/../../www/images/');
779
+			$destinationPath = realpath(__DIR__.'/../../www/images/');
780 780
 
781 781
 			$filename = $this->validateFilename($postValues['name'], $destinationPath);
782
-			$destination = $destinationPath . '/' . $filename;
782
+			$destination = $destinationPath.'/'.$filename;
783 783
 
784 784
 			if ($postValues['error'] != '0') {
785
-				throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
785
+				throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
786 786
 			}
787 787
 
788 788
 			if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -807,14 +807,14 @@  discard block
 block discarded – undo
807 807
 
808 808
 		public function deleteImageByName($filename)
809 809
 		{
810
-			$destinationPath = realpath(__DIR__ . '/../../www/images/');
810
+			$destinationPath = realpath(__DIR__.'/../../www/images/');
811 811
 
812 812
 			$images = $this->getImages();
813 813
 
814 814
 			foreach ($images as $key => $image) {
815 815
 				if ($image->file == $filename) {
816 816
 					foreach ($image->set as $imageSetFilename) {
817
-						$destination = $destinationPath . '/' . $imageSetFilename;
817
+						$destination = $destinationPath.'/'.$imageSetFilename;
818 818
 						if (file_exists($destination)) {
819 819
 							unlink($destination);
820 820
 						} else {
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		 */
857 857
 		public function getFiles()
858 858
 		{
859
-			$files =  $this->repository->files;
859
+			$files = $this->repository->files;
860 860
 			usort($files, array($this, 'compareFiles'));
861 861
 			return $files;
862 862
 		}
@@ -868,13 +868,13 @@  discard block
 block discarded – undo
868 868
 
869 869
 		public function addFile($postValues)
870 870
 		{
871
-			$destinationPath = realpath(__DIR__ . '/../../www/files/');
871
+			$destinationPath = realpath(__DIR__.'/../../www/files/');
872 872
 
873 873
 			$filename = $this->validateFilename($postValues['name'], $destinationPath);
874
-			$destination = $destinationPath . '/' . $filename;
874
+			$destination = $destinationPath.'/'.$filename;
875 875
 
876 876
 			if ($postValues['error'] != '0') {
877
-				throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
877
+				throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
878 878
 			}
879 879
 
880 880
 			if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -900,23 +900,23 @@  discard block
 block discarded – undo
900 900
 				array_pop($fileParts);
901 901
 				$fileNameWithoutExtension = implode('-', $fileParts);
902 902
 				$fileNameWithoutExtension = slugify($fileNameWithoutExtension);
903
-				$filename = $fileNameWithoutExtension . '.' . $extension;
903
+				$filename = $fileNameWithoutExtension.'.'.$extension;
904 904
 			} else {
905 905
 				$filename = slugify($filename);
906 906
 			}
907 907
 
908
-			if (file_exists($path . '/' . $filename)) {
908
+			if (file_exists($path.'/'.$filename)) {
909 909
 				$fileParts = explode('.', $filename);
910 910
 				if (count($fileParts) > 1) {
911 911
 					$extension = end($fileParts);
912 912
 					array_pop($fileParts);
913 913
 					$fileNameWithoutExtension = implode('-', $fileParts);
914 914
 					$fileNameWithoutExtension .= '-copy';
915
-					$filename = $fileNameWithoutExtension . '.' . $extension;
915
+					$filename = $fileNameWithoutExtension.'.'.$extension;
916 916
 				} else {
917 917
 					$filename .= '-copy';
918 918
 				}
919
-				return $this->validateFilename($filename,$path);
919
+				return $this->validateFilename($filename, $path);
920 920
 			}
921 921
 			return $filename;
922 922
 		}
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
          */
943 943
 		public function deleteFileByName($filename)
944 944
 		{
945
-			$destinationPath = realpath(__DIR__ . '/../../www/files/');
946
-			$destination = $destinationPath . '/' . $filename;
945
+			$destinationPath = realpath(__DIR__.'/../../www/files/');
946
+			$destination = $destinationPath.'/'.$filename;
947 947
 
948 948
 			if (file_exists($destination)) {
949 949
 				$files = $this->getFiles();
Please login to merge, or discard this patch.
cloudcontrol/library/storage/Repository.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             if (in_array($name, $this->fileBasedSubsets)) {
93 93
                 return $this->loadSubset($name);
94 94
             } else {
95
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
95
+                throw new \Exception('Trying to get undefined property from Repository: '.$name);
96 96
             }
97 97
         }
98 98
     }
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
     {
102 102
         if (in_array($name, $this->fileBasedSubsets)) {
103 103
             $this->$name = $value;
104
-            $changes = $name . 'Changes';
104
+            $changes = $name.'Changes';
105 105
             $this->$changes = true;
106 106
         } else {
107
-            throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
107
+            throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>');
108 108
         }
109 109
     }
110 110
 
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
     protected function saveSubset($subset)
124 124
     {
125 125
         $json = json_encode($this->$subset);
126
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
126
+        $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
127 127
         file_put_contents($subsetStoragePath, $json);
128
-        $changes = $subset . 'Changes';
128
+        $changes = $subset.'Changes';
129 129
         $this->$changes = false;
130 130
     }
131 131
 
132 132
     protected function loadSubset($subset)
133 133
     {
134
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
134
+        $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
135 135
         $json = file_get_contents($subsetStoragePath);
136 136
         $json = json_decode($json);
137 137
         $this->$subset = $json;
Please login to merge, or discard this patch.