Completed
Push — master ( 077859...60e689 )
by Mateusz
07:31
created
code/model/DNDataArchive.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	}
122 122
 
123 123
 	public function onBeforeWrite() {
124
-		if(!$this->AuthorID) {
124
+		if (!$this->AuthorID) {
125 125
 			$this->AuthorID = Member::currentUserID();
126 126
 		}
127 127
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @return string The human-readable size of this archive file
180 180
 	 */
181 181
 	public function FileSize() {
182
-		if($this->ArchiveFile()->exists()) {
182
+		if ($this->ArchiveFile()->exists()) {
183 183
 			return $this->ArchiveFile()->getSize();
184 184
 		} else {
185 185
 			return "N/A";
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	}
188 188
 
189 189
 	public function getModeNice() {
190
-		if($this->Mode == 'all') {
190
+		if ($this->Mode == 'all') {
191 191
 			return 'database and assets';
192 192
 		} else {
193 193
 			return $this->Mode;
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	public function canRestore($member = null) {
225 225
 		$memberID = $member ? $member->ID : Member::currentUserID();
226
-		if(!$memberID) {
226
+		if (!$memberID) {
227 227
 			return false;
228 228
 		}
229 229
 
230
-		$key = $memberID . '-' . $this->EnvironmentID;
231
-		if(!isset(self::$_cache_can_restore[$key])) {
230
+		$key = $memberID.'-'.$this->EnvironmentID;
231
+		if (!isset(self::$_cache_can_restore[$key])) {
232 232
 			self::$_cache_can_restore[$key] = $this->Environment()->canUploadArchive($member);
233 233
 		}
234 234
 
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function canDownload($member = null) {
246 246
 		$memberID = $member ? $member->ID : Member::currentUserID();
247
-		if(!$memberID) {
247
+		if (!$memberID) {
248 248
 			return false;
249 249
 		}
250 250
 
251
-		$key = $memberID . '-' . $this->EnvironmentID;
252
-		if(!isset(self::$_cache_can_download[$key])) {
251
+		$key = $memberID.'-'.$this->EnvironmentID;
252
+		if (!isset(self::$_cache_can_download[$key])) {
253 253
 			self::$_cache_can_download[$key] = $this->Environment()->canDownloadArchive($member);
254 254
 		}
255 255
 		return self::$_cache_can_download[$key];
@@ -274,27 +274,27 @@  discard block
 block discarded – undo
274 274
 	 * @return boolean true if $member can upload archives linked to this environment, false if they can't.
275 275
 	 */
276 276
 	public function canMoveTo($targetEnv, $member = null) {
277
-		if($this->Environment()->Project()->ID != $targetEnv->Project()->ID) {
277
+		if ($this->Environment()->Project()->ID != $targetEnv->Project()->ID) {
278 278
 			// We don't permit moving snapshots between projects at this stage.
279 279
 			return false;
280 280
 		}
281 281
 
282
-		if(!$member) {
282
+		if (!$member) {
283 283
 			$member = Member::currentUser();
284 284
 		}
285 285
 
286 286
 		// Must be logged in to check permissions
287
-		if(!$member) {
287
+		if (!$member) {
288 288
 			return false;
289 289
 		}
290 290
 
291 291
 		// Admin can always move.
292
-		if(Permission::checkMember($member, 'ADMIN')) {
292
+		if (Permission::checkMember($member, 'ADMIN')) {
293 293
 			return true;
294 294
 		}
295 295
 
296 296
 		// Checks if the user can actually access the archive.
297
-		if(!$this->canDownload($member)) {
297
+		if (!$this->canDownload($member)) {
298 298
 			return false;
299 299
 		}
300 300
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 * @return bool
404 404
 	 */
405 405
 	public function extractArchive($workingDir = null) {
406
-		if(!is_dir($workingDir)) {
406
+		if (!is_dir($workingDir)) {
407 407
 			mkdir($workingDir, 0700, true);
408 408
 		}
409 409
 
@@ -422,28 +422,28 @@  discard block
 block discarded – undo
422 422
 		));
423 423
 		$process->setTimeout(3600);
424 424
 		$process->run();
425
-		if(!$process->isSuccessful()) {
425
+		if (!$process->isSuccessful()) {
426 426
 			$cleanupFn();
427 427
 			throw new RuntimeException(sprintf('Could not extract the sspak file: %s', $process->getErrorOutput()));
428 428
 		}
429 429
 
430 430
 		// Extract database.sql.gz to <workingdir>/database.sql
431
-		if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'database.sql.gz')) {
431
+		if (file_exists($workingDir.DIRECTORY_SEPARATOR.'database.sql.gz')) {
432 432
 			$process = new AbortableProcess('gunzip database.sql.gz', $workingDir);
433 433
 			$process->setTimeout(3600);
434 434
 			$process->run();
435
-			if(!$process->isSuccessful()) {
435
+			if (!$process->isSuccessful()) {
436 436
 				$cleanupFn();
437 437
 				throw new RuntimeException(sprintf('Could not extract the db archive: %s', $process->getErrorOutput()));
438 438
 			}
439 439
 		}
440 440
 
441 441
 		// Extract assets.tar.gz to <workingdir>/assets/
442
-		if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'assets.tar.gz')) {
442
+		if (file_exists($workingDir.DIRECTORY_SEPARATOR.'assets.tar.gz')) {
443 443
 			$process = new AbortableProcess('tar xzf assets.tar.gz', $workingDir);
444 444
 			$process->setTimeout(3600);
445 445
 			$process->run();
446
-			if(!$process->isSuccessful()) {
446
+			if (!$process->isSuccessful()) {
447 447
 				$cleanupFn();
448 448
 				throw new RuntimeException(sprintf('Could not extract the assets archive: %s', $process->getErrorOutput()));
449 449
 			}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 
468 468
 		$file = $this->ArchiveFile()->FullPath;
469 469
 
470
-		if(!is_readable($file)) {
470
+		if (!is_readable($file)) {
471 471
 			$result->error(sprintf('SSPak file "%s" cannot be read.', $file));
472 472
 			return $result;
473 473
 		}
@@ -475,19 +475,19 @@  discard block
 block discarded – undo
475 475
 		$process = new AbortableProcess(sprintf('tar -tf %s', escapeshellarg($file)));
476 476
 		$process->setTimeout(120);
477 477
 		$process->run();
478
-		if(!$process->isSuccessful()) {
478
+		if (!$process->isSuccessful()) {
479 479
 			throw new RuntimeException(sprintf('Could not list files in archive: %s', $process->getErrorOutput()));
480 480
 		}
481 481
 
482 482
 		$output = explode(PHP_EOL, $process->getOutput());
483 483
 		$files = array_filter($output);
484 484
 
485
-		if(in_array($mode, array('all', 'db')) && !in_array('database.sql.gz', $files)) {
485
+		if (in_array($mode, array('all', 'db')) && !in_array('database.sql.gz', $files)) {
486 486
 			$result->error('The snapshot is missing the database.');
487 487
 			return $result;
488 488
 		}
489 489
 
490
-		if(in_array($mode, array('all', 'assets')) && !in_array('assets.tar.gz', $files)) {
490
+		if (in_array($mode, array('all', 'assets')) && !in_array('assets.tar.gz', $files)) {
491 491
 			$result->error('The snapshot is missing assets.');
492 492
 			return $result;
493 493
 		}
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
 			sprintf('find %s -type f -exec chmod 644 {} +', escapeshellarg($workingDir))
518 518
 		);
519 519
 
520
-		foreach($fixCmds as $cmd) {
520
+		foreach ($fixCmds as $cmd) {
521 521
 			$process = new AbortableProcess($cmd);
522 522
 			$process->setTimeout(3600);
523 523
 			$process->run();
524
-			if(!$process->isSuccessful()) {
524
+			if (!$process->isSuccessful()) {
525 525
 				throw new RuntimeException($process->getErrorOutput());
526 526
 			}
527 527
 		}
@@ -540,11 +540,11 @@  discard block
 block discarded – undo
540 540
 	 */
541 541
 	public function setArchiveFromFiles($workingDir) {
542 542
 		$commands = array();
543
-		if($this->Mode == 'db') {
543
+		if ($this->Mode == 'db') {
544 544
 			$commands[] = 'gzip database.sql';
545 545
 			$commands[] = sprintf('tar -cf %s database.sql.gz', $this->ArchiveFile()->FullPath);
546 546
 			$commands[] = 'rm -f database.sql.gz';
547
-		} elseif($this->Mode == 'assets') {
547
+		} elseif ($this->Mode == 'assets') {
548 548
 			$commands[] = 'GZIP=-1 tar --dereference -czf assets.tar.gz assets';
549 549
 			$commands[] = sprintf('tar -cf %s assets.tar.gz', $this->ArchiveFile()->FullPath);
550 550
 			$commands[] = 'rm -f assets.tar.gz';
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 		$process = new AbortableProcess(implode(' && ', $commands), $workingDir);
559 559
 		$process->setTimeout(3600);
560 560
 		$process->run();
561
-		if(!$process->isSuccessful()) {
561
+		if (!$process->isSuccessful()) {
562 562
 			throw new RuntimeException($process->getErrorOutput());
563 563
 		}
564 564
 
Please login to merge, or discard this patch.
code/model/jobs/DNCreateEnvironment.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return string
69 69
 	 */
70 70
 	public function LogLink() {
71
-		return $this->Link() . '/log';
71
+		return $this->Link().'/log';
72 72
 	}
73 73
 
74 74
 	/**
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 		$status = new Resque_Job_Status($this->ResqueToken);
111 111
 		$statusCode = $status->get();
112 112
 		// The Resque job can no longer be found, fallback to the DNDeployment.Status
113
-		if($statusCode === false) {
113
+		if ($statusCode === false) {
114 114
 			// Translate from the DNDeployment.Status to the Resque job status for UI purposes
115
-			switch($this->Status) {
115
+			switch ($this->Status) {
116 116
 				case 'Finished':
117 117
 					return 'Complete';
118 118
 				case 'Started':
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 			'projectName' => $project->Name
140 140
 		);
141 141
 
142
-		if(!$this->CreatorID) {
142
+		if (!$this->CreatorID) {
143 143
 			$this->CreatorID = Member::currentUserID();
144 144
 		}
145 145
 
146
-		if($this->CreatorID) {
146
+		if ($this->CreatorID) {
147 147
 			$creator = $this->Creator();
148 148
 			$message = sprintf(
149 149
 				'Environment creation for project %s initiated by %s (%s), with IP address %s',
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 	public function createEnvironment() {
173 173
 		$backend = $this->getBackend();
174
-		if($backend) {
174
+		if ($backend) {
175 175
 			return $backend->createEnvironment($this);
176 176
 		}
177 177
 		throw new Exception("Unable to find backend.");
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	public function getBackend() {
187 187
 		$data = unserialize($this->Data);
188
-		if(isset($data['EnvironmentType']) && class_exists($data['EnvironmentType'])) {
188
+		if (isset($data['EnvironmentType']) && class_exists($data['EnvironmentType'])) {
189 189
 			$env = Injector::inst()->get($data['EnvironmentType']);
190
-			if($env instanceof EnvironmentCreateBackend) {
190
+			if ($env instanceof EnvironmentCreateBackend) {
191 191
 				return $env;
192 192
 			} else {
193
-				throw new Exception("Invalid backend: " . $data['EnvironmentType']);
193
+				throw new Exception("Invalid backend: ".$data['EnvironmentType']);
194 194
 			}
195 195
 		}
196 196
 		return null;
Please login to merge, or discard this patch.
code/model/jobs/DNDataTransfer.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	public function getTitle() {
115
-		return $this->dbObject('Created')->Nice() . " (Status: {$this->Status})";
115
+		return $this->dbObject('Created')->Nice()." (Status: {$this->Status})";
116 116
 	}
117 117
 
118 118
 	public function Link() {
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 			'backupBeforePush' => $this->backupBeforePush
170 170
 		);
171 171
 
172
-		if(!$this->AuthorID) {
172
+		if (!$this->AuthorID) {
173 173
 			$this->AuthorID = Member::currentUserID();
174 174
 		}
175 175
 
176
-		if($this->AuthorID) {
176
+		if ($this->AuthorID) {
177 177
 			$author = $this->Author();
178 178
 			$message = sprintf(
179 179
 				'Data transfer on %s (%s, %s) initiated by %s (%s), with IP address %s',
@@ -231,23 +231,23 @@  discard block
 block discarded – undo
231 231
 
232 232
 	public function getDescription() {
233 233
 		$envName = $this->Environment()->getFullName();
234
-		if($this->Direction == 'get') {
235
-			if($this->Origin == 'ManualUpload') {
236
-				$description = 'Manual upload of ' . $this->getModeNice() . ' to ' . $envName;
237
-			} elseif($this->IsBackupDataTransfer()) {
238
-				$description = 'Automated backup of ' . $this->getModeNice() . ' from ' . $envName;
234
+		if ($this->Direction == 'get') {
235
+			if ($this->Origin == 'ManualUpload') {
236
+				$description = 'Manual upload of '.$this->getModeNice().' to '.$envName;
237
+			} elseif ($this->IsBackupDataTransfer()) {
238
+				$description = 'Automated backup of '.$this->getModeNice().' from '.$envName;
239 239
 			} else {
240
-				$description = 'Backup of ' . $this->getModeNice() . ' to ' . $envName;
240
+				$description = 'Backup of '.$this->getModeNice().' to '.$envName;
241 241
 			}
242 242
 		} else {
243
-			$description = 'Restore ' . $this->getModeNice() . ' to ' . $envName;
243
+			$description = 'Restore '.$this->getModeNice().' to '.$envName;
244 244
 		}
245 245
 
246 246
 		return $description;
247 247
 	}
248 248
 
249 249
 	public function getModeNice() {
250
-		if($this->Mode == 'all') {
250
+		if ($this->Mode == 'all') {
251 251
 			return 'database and assets';
252 252
 		} else {
253 253
 			return $this->Mode;
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 		$status = new Resque_Job_Status($this->ResqueToken);
288 288
 		$statusCode = $status->get();
289 289
 		// The Resque job can no longer be found, fallback to the DNDataTransfer.Status
290
-		if($statusCode === false) {
290
+		if ($statusCode === false) {
291 291
 			// Translate from the DNDataTransfer.Status to the Resque job status for UI purposes
292
-			switch($this->Status) {
292
+			switch ($this->Status) {
293 293
 				case 'Finished':
294 294
 					return 'Complete';
295 295
 				case 'Started':
Please login to merge, or discard this patch.
code/model/jobs/DNGitFetch.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 		$project = $this->Project();
55 55
 		$log = $this->log();
56 56
 
57
-		if(!$this->DeployerID) {
57
+		if (!$this->DeployerID) {
58 58
 			$this->DeployerID = Member::currentUserID();
59 59
 		}
60 60
 
61
-		if($this->DeployerID) {
61
+		if ($this->DeployerID) {
62 62
 			$deployer = $this->Deployer();
63 63
 			$message = sprintf(
64 64
 				'Update repository job for %s initiated by %s (%s)',
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 		$status = new Resque_Job_Status($this->ResqueToken);
132 132
 		$statusCode = $status->get();
133 133
 		// The Resque job can no longer be found, fallback to the DNDeployment.Status
134
-		if($statusCode === false) {
134
+		if ($statusCode === false) {
135 135
 			// Translate from the DNDeployment.Status to the Resque job status for UI purposes
136
-			switch($this->Status) {
136
+			switch ($this->Status) {
137 137
 				case 'Finished':
138 138
 					return 'Complete';
139 139
 				case 'Started':
Please login to merge, or discard this patch.
code/model/jobs/DNPing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @return string
38 38
 	 */
39 39
 	public function LogLink() {
40
-		return $this->Link() . '/log';
40
+		return $this->Link().'/log';
41 41
 	}
42 42
 
43 43
 	/**
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 			'pingID' => $this->ID
108 108
 		);
109 109
 
110
-		if(!$this->DeployerID) {
110
+		if (!$this->DeployerID) {
111 111
 			$this->DeployerID = Member::currentUserID();
112 112
 		}
113 113
 
114
-		if($this->DeployerID) {
114
+		if ($this->DeployerID) {
115 115
 			$deployer = $this->Deployer();
116 116
 			$message = sprintf(
117 117
 				'Ping to %s initiated by %s (%s)',
Please login to merge, or discard this patch.
code/model/jobs/DNDeployment.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	public function LogLink() {
104
-		return $this->Link() . '/log';
104
+		return $this->Link().'/log';
105 105
 	}
106 106
 
107 107
 	public function canView($member = null) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return \Gitonomy\Git\Repository|null
148 148
 	 */
149 149
 	public function getRepository() {
150
-		if(!$this->SHA) {
150
+		if (!$this->SHA) {
151 151
 			return null;
152 152
 		}
153 153
 		return $this->Environment()->Project()->getRepository();
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function getCommit() {
162 162
 		$repo = $this->getRepository();
163
-		if($repo) {
163
+		if ($repo) {
164 164
 			try {
165 165
 				return $repo->getCommit($this->SHA);
166
-			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) {
166
+			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) {
167 167
 				return null;
168 168
 			}
169 169
 		}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		if (!$interface) {
189 189
 			return null;
190 190
 		}
191
-		return $interface->CommitURL . '/' . $this->SHA;
191
+		return $interface->CommitURL.'/'.$this->SHA;
192 192
 	}
193 193
 
194 194
 	/**
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function getCommitMessage() {
200 200
 		$commit = $this->getCommit();
201
-		if($commit) {
201
+		if ($commit) {
202 202
 			try {
203 203
 				return Convert::raw2xml($commit->getMessage());
204
-			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) {
204
+			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) {
205 205
 				return null;
206 206
 			}
207 207
 		}
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	public function getTags() {
217 217
 		$returnTags = array();
218 218
 		$repo = $this->getRepository();
219
-		if($repo) {
219
+		if ($repo) {
220 220
 			$tags = $repo->getReferences()->resolveTags($this->SHA);
221
-			if(!empty($tags)) {
222
-				foreach($tags as $tag) {
221
+			if (!empty($tags)) {
222
+				foreach ($tags as $tag) {
223 223
 					$field = Varchar::create('Tag', '255');
224 224
 					$field->setValue($tag->getName());
225 225
 					$returnTags[] = $field;
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function getFullDeployMessages() {
239 239
 		$strategy = $this->getDeploymentStrategy();
240
-		if ($strategy->getActionCode()!=='full') return null;
240
+		if ($strategy->getActionCode() !== 'full') return null;
241 241
 
242 242
 		$changes = $strategy->getChangesModificationNeeded();
243 243
 		$messages = [];
244 244
 		foreach ($changes as $change => $details) {
245
-			if ($change==='Code version') continue;
245
+			if ($change === 'Code version') continue;
246 246
 
247 247
 			$messages[] = [
248 248
 				'Flag' => sprintf(
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 */
271 271
 	public function getTag() {
272 272
 		$tags = $this->getTags();
273
-		if($tags->count() > 0) {
273
+		if ($tags->count() > 0) {
274 274
 			return $tags->last();
275 275
 		}
276 276
 		return null;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	public function getChanges() {
296 296
 		$list = new ArrayList();
297 297
 		$strategy = $this->getDeploymentStrategy();
298
-		foreach($strategy->getChanges() as $name => $change) {
298
+		foreach ($strategy->getChanges() as $name => $change) {
299 299
 			$changed = (isset($change['from']) && isset($change['to'])) ? $change['from'] != $change['to'] : null;
300 300
 			$description = isset($change['description']) ? $change['description'] : '';
301 301
 			$compareUrl = null;
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 		// Make sure we use the SHA as it was written into this DNDeployment.
346 346
 		$args['sha'] = $this->SHA;
347 347
 
348
-		if(!$this->DeployerID) {
348
+		if (!$this->DeployerID) {
349 349
 			$this->DeployerID = Member::currentUserID();
350 350
 		}
351 351
 
352
-		if($this->DeployerID) {
352
+		if ($this->DeployerID) {
353 353
 			$deployer = $this->Deployer();
354 354
 			$message = sprintf(
355 355
 				'Deploy to %s initiated by %s (%s), with IP address %s',
Please login to merge, or discard this patch.
code/model/DNData.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		parent::__construct();
60 60
 
61 61
 		// Better to use injector to set these
62
-		if(func_num_args() == 0) {
62
+		if (func_num_args() == 0) {
63 63
 			return;
64 64
 		}
65 65
 		Deprecation::notice(
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 * @param string $environmentDir
89 89
 	 */
90 90
 	public function setEnvironmentDir($environmentDir) {
91
-		if($environmentDir[0] != "/") {
92
-			$environmentDir = BASE_PATH . '/' . $environmentDir;
91
+		if ($environmentDir[0] != "/") {
92
+			$environmentDir = BASE_PATH.'/'.$environmentDir;
93 93
 		}
94 94
 		$this->environmentDir = realpath($environmentDir) ?: $environmentDir;
95 95
 	}
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param string $keyDir
110 110
 	 */
111 111
 	public function setKeyDir($keyDir) {
112
-		if($keyDir[0] != "/") {
113
-			$keyDir = BASE_PATH . '/' . $keyDir;
112
+		if ($keyDir[0] != "/") {
113
+			$keyDir = BASE_PATH.'/'.$keyDir;
114 114
 		}
115 115
 		$this->keyDir = realpath($keyDir) ?: $keyDir;
116 116
 	}
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @param string $signalDir
127 127
 	 */
128 128
 	public function setSignalDir($signalDir) {
129
-		if($signalDir[0] != "/") {
130
-			$signalDir = BASE_PATH . '/' . $signalDir;
129
+		if ($signalDir[0] != "/") {
130
+			$signalDir = BASE_PATH.'/'.$signalDir;
131 131
 		}
132 132
 		$this->signalDir = realpath($signalDir) ?: $signalDir;
133 133
 	}
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 	 * @param string $transferDir
169 169
 	 */
170 170
 	public function setDataTransferDir($transferDir) {
171
-		if($transferDir[0] != "/") {
172
-			$transferDir = BASE_PATH . '/' . $transferDir;
171
+		if ($transferDir[0] != "/") {
172
+			$transferDir = BASE_PATH.'/'.$transferDir;
173 173
 		}
174
-		if(strpos($transferDir, ASSETS_PATH) === false) {
174
+		if (strpos($transferDir, ASSETS_PATH) === false) {
175 175
 			throw new LogicException(sprintf(
176 176
 				'DNData::dataTransferDir needs to be located within <webroot>assets/ (location: %s)',
177 177
 				$transferDir
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function getProjectPaths() {
200 200
 		$paths = array();
201
-		if(!file_exists($this->getEnvironmentDir())) {
202
-			$eMessage = 'The environment directory ' . $this->getEnvironmentDir() . ' doesn\'t exist. Create it '
201
+		if (!file_exists($this->getEnvironmentDir())) {
202
+			$eMessage = 'The environment directory '.$this->getEnvironmentDir().' doesn\'t exist. Create it '
203 203
 			. 'first and add some projects to it.';
204 204
 			throw new Exception($eMessage);
205 205
 		}
206
-		foreach(scandir($this->getEnvironmentDir()) as $project) {
206
+		foreach (scandir($this->getEnvironmentDir()) as $project) {
207 207
 			// Exlcude dot-prefixed directories (.git was getting in the way)
208
-			if(preg_match('/^[^\.]/', $project)) {
209
-				$path = $this->getEnvironmentDir() . '/' . $project;
210
-				if(is_dir($path) && $project != '.' && $project != '..') {
208
+			if (preg_match('/^[^\.]/', $project)) {
209
+				$path = $this->getEnvironmentDir().'/'.$project;
210
+				if (is_dir($path) && $project != '.' && $project != '..') {
211 211
 					$paths[] = $project;
212 212
 				}
213 213
 			}
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
 	 * Returns an array of paths
222 222
 	 */
223 223
 	public function getEnvironmentPaths($project) {
224
-		$baseDir = $this->getEnvironmentDir() . '/' . $project;
224
+		$baseDir = $this->getEnvironmentDir().'/'.$project;
225 225
 
226 226
 		$paths = array();
227
-		if(!file_exists($baseDir)) {
228
-			throw new Exception('Environment directory ' . $baseDir . ' doesn\'t exist. Create it first.');
227
+		if (!file_exists($baseDir)) {
228
+			throw new Exception('Environment directory '.$baseDir.' doesn\'t exist. Create it first.');
229 229
 		}
230 230
 		// Search the directory for config files.
231
-		foreach(scandir($baseDir) as $environmentFile) {
232
-			if(preg_match('/\.rb$/', $environmentFile)) {
231
+		foreach (scandir($baseDir) as $environmentFile) {
232
+			if (preg_match('/\.rb$/', $environmentFile)) {
233 233
 				// Config found, wrap it into an object.
234 234
 				$paths[] = "$baseDir/$environmentFile";
235 235
 			}
Please login to merge, or discard this patch.
code/model/DNCommit.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @return string
75 75
 	 */
76 76
 	public function Name() {
77
-		if($this->name == null) {
77
+		if ($this->name == null) {
78 78
 			$this->name = $this->commit->getFixedShortHash(8);
79 79
 		}
80 80
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return string
95 95
 	 */
96 96
 	public function SubjectMessage() {
97
-		if($this->subjectMessage == null) {
97
+		if ($this->subjectMessage == null) {
98 98
 			$this->subjectMessage = $this->commit->getSubjectMessage();
99 99
 		}
100 100
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	public function BodyMessage() {
105
-		if($this->bodyMessage == null) {
105
+		if ($this->bodyMessage == null) {
106 106
 			$this->bodyMessage = $this->commit->getBodyMessage();
107 107
 		}
108 108
 
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 	 * @return ArrayList
114 114
 	 */
115 115
 	public function References() {
116
-		if($this->references !== null) {
116
+		if ($this->references !== null) {
117 117
 			return $this->references;
118 118
 		}
119 119
 		$this->references = new ArrayList();
120 120
 
121 121
 		// Add tags
122
-		foreach($this->commit->resolveReferences() as $reference) {
123
-			if($reference instanceof \Gitonomy\Git\Reference\Tag) {
122
+		foreach ($this->commit->resolveReferences() as $reference) {
123
+			if ($reference instanceof \Gitonomy\Git\Reference\Tag) {
124 124
 				$this->references->push(new ArrayData(array(
125 125
 					'Name' => $reference->getName(),
126 126
 					'Type' => 'Tag',
@@ -151,16 +151,16 @@  discard block
 block discarded – undo
151 151
 	public function CurrentlyDeployedTo() {
152 152
 		$environments = $this->project->Environments();
153 153
 		$envList = new ArrayList();
154
-		foreach($environments as $environment) {
154
+		foreach ($environments as $environment) {
155 155
 			$deployments = DNDeployment::get()
156 156
 				->filter('State', 'Completed')
157 157
 				->filter('EnvironmentID', $environment->ID)
158 158
 				->sort('LastEdited DESC');
159
-			if(!$deployments->count()) {
159
+			if (!$deployments->count()) {
160 160
 				continue;
161 161
 			}
162 162
 			$latest = $deployments->first();
163
-			if($latest->SHA === $this->commit->getHash()) {
163
+			if ($latest->SHA === $this->commit->getHash()) {
164 164
 				$envList->push($environment);
165 165
 			}
166 166
 		}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	public function EverDeployedTo($environmentName) {
175 175
 		$environments = $this->project->Environments()->filter('Name', $environmentName);
176
-		if(!$environments->count()) {
176
+		if (!$environments->count()) {
177 177
 			return false;
178 178
 		}
179 179
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 				->filter('State', 'Completed')
184 184
 				->filter('EnvironmentID', $environment->ID);
185 185
 
186
-		if($deployments->count()) {
186
+		if ($deployments->count()) {
187 187
 			return true;
188 188
 		}
189 189
 
Please login to merge, or discard this patch.
code/model/DNReferenceList.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -100,24 +100,24 @@  discard block
 block discarded – undo
100 100
 	protected function getReferences() {
101 101
 		try {
102 102
 			$repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
103
-		} catch(Exception $e) {
103
+		} catch (Exception $e) {
104 104
 			return array();
105 105
 		}
106 106
 
107
-		if($this->getTags) {
108
-			if($this->reference) {
107
+		if ($this->getTags) {
108
+			if ($this->reference) {
109 109
 				throw new LogicException("Can't have \$reference and \$getTags both set");
110 110
 			}
111 111
 			$log = $repository->getReferences()->getTags();
112 112
 
113
-		} else if($this->reference) {
113
+		} else if ($this->reference) {
114 114
 			$log = $this->reference->getLog();
115 115
 		} else {
116 116
 			$log = $repository->getLog();
117 117
 		}
118 118
 
119
-		if($this->limit) {
120
-			if(is_array($log)) {
119
+		if ($this->limit) {
120
+			if (is_array($log)) {
121 121
 				$limitedLog = array_slice($log, 0, $this->limit);
122 122
 			} else {
123 123
 				$limitedLog = $log->setLimit($this->limit);
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 
129 129
 		// cache them for look up in byName
130 130
 		$builds = array();
131
-		foreach($limitedLog as $reference) {
132
-			if(!empty($this->blockBranch)) {
131
+		foreach ($limitedLog as $reference) {
132
+			if (!empty($this->blockBranch)) {
133 133
 				$branchesIncluding = GitonomyCache::getIncludingBranches($reference);
134
-				foreach($branchesIncluding as $candidate) {
135
-					if($candidate->getName() == $this->blockBranch) {
134
+				foreach ($branchesIncluding as $candidate) {
135
+					if ($candidate->getName() == $this->blockBranch) {
136 136
 						// Break out of the function
137 137
 						return $builds;
138 138
 					}
139 139
 				}
140 140
 			}
141 141
 
142
-			if($this->getTags) {
142
+			if ($this->getTags) {
143 143
 				$builds[] = DNTag::create($reference, $this->project, $this->data);
144 144
 			} else {
145 145
 				$name = $this->reference ? $this->reference->getName() : '';
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return DNCommit
158 158
 	 */
159 159
 	public function byName($hash) {
160
-		if($this->loaded === false) {
160
+		if ($this->loaded === false) {
161 161
 			$this->items = $this->getReferences();
162 162
 			$this->loaded = true;
163 163
 		}
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 		// The item might not be in the list because of the limit, try to find
166 166
 		// in an older version and add it to the list.
167 167
 		$found = null;
168
-		foreach($this->items as $item) {
169
-			if($item->SHA() == $hash) {
168
+		foreach ($this->items as $item) {
169
+			if ($item->SHA() == $hash) {
170 170
 				$found = $item;
171 171
 				break;
172 172
 			}
173 173
 		}
174 174
 
175
-		if($found === null) {
175
+		if ($found === null) {
176 176
 			$repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
177 177
 			$commit = new Gitonomy\Git\Commit($repository, $hash);
178 178
 			$found = DNCommit::create($commit, $this->project, $this->data);
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 	 * @return ArrayIterator
194 194
 	 */
195 195
 	public function getIterator() {
196
-		if($this->loaded === false) {
196
+		if ($this->loaded === false) {
197 197
 			$this->items = $this->getReferences();
198 198
 			$this->loaded = true;
199 199
 		}
200
-		foreach($this->items as $item) {
201
-			if(is_array($item)) {
200
+		foreach ($this->items as $item) {
201
+			if (is_array($item)) {
202 202
 				$this->items[] = new ArrayData($item);
203 203
 			}
204 204
 		}
Please login to merge, or discard this patch.