Completed
Push — master ( 0e2358...5e7c93 )
by Sean
06:29 queued 02:57
created
code/queuereport/ResqueJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 	 * @return mixed
61 61
 	 */
62 62
 	public function __get($property) {
63
-		if(isset($this->record[$property])) {
63
+		if (isset($this->record[$property])) {
64 64
 			return $this->record[$property];
65 65
 		}
66 66
 		return null;
Please login to merge, or discard this patch.
code/queuereport/ResqueQueue.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 	protected function getJobs() {
50 50
 		$jobs = new ArrayList();
51 51
 
52
-		$resqueJobs = Resque::redis()->lrange('queue:' . $this->Name, 0, -1);
53
-		if(!$resqueJobs) {
52
+		$resqueJobs = Resque::redis()->lrange('queue:'.$this->Name, 0, -1);
53
+		if (!$resqueJobs) {
54 54
 			$jobs->push(new ResqueJob(array(
55 55
 				'Name' => 'null',
56 56
 				'Value' => 'null',
57 57
 			)));
58 58
 			return $jobs;
59 59
 		}
60
-		foreach($resqueJobs as $idx => $job) {
60
+		foreach ($resqueJobs as $idx => $job) {
61 61
 			$stdClass = json_decode($job);
62
-			if($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') {
62
+			if ($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') {
63 63
 				$value = $stdClass->args[0]->projectName
64
-					. ':' . $stdClass->args[0]->environment
65
-					. ' - ' . $stdClass->args[0]->sha;
64
+					. ':'.$stdClass->args[0]->environment
65
+					. ' - '.$stdClass->args[0]->sha;
66 66
 				$jobs->push(new ResqueJob(array(
67 67
 					'Name' => $stdClass->class,
68 68
 					'Value' => $value,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return mixed
112 112
 	 */
113 113
 	public function __get($property) {
114
-		if(isset($this->record[$property])) {
114
+		if (isset($this->record[$property])) {
115 115
 			return $this->record[$property];
116 116
 		}
117 117
 		return null;
Please login to merge, or discard this patch.
code/AbortableProcess.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 class AbortableProcess extends \Symfony\Component\Process\Process {
16 16
 	public function run($callback = null) {
17 17
 		$this->start($callback);
18
-		while($this->isRunning()) {
18
+		while ($this->isRunning()) {
19 19
 			$this->checkTimeout();
20 20
 			sleep(1);
21 21
 		}
Please login to merge, or discard this patch.
code/jobs/DeployJob.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	public function alarmHandler() {
19 19
 		$sigFile = $this->args['sigFile'];
20 20
 		if (file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) {
21
-			$signal = (int)file_get_contents($sigFile);
22
-			if (is_int($signal) && in_array((int)$signal, [
21
+			$signal = (int) file_get_contents($sigFile);
22
+			if (is_int($signal) && in_array((int) $signal, [
23 23
 				// The following signals are trapped by both Resque and Rainforest.
24 24
 				SIGTERM,
25 25
 				SIGINT,
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 				SIGCONT
31 31
 			])) {
32 32
 				echo sprintf(
33
-					'[-] Signal "%s" received, delivering to own process group, PID "%s".' . PHP_EOL,
33
+					'[-] Signal "%s" received, delivering to own process group, PID "%s".'.PHP_EOL,
34 34
 					$signal,
35 35
 					getmypid()
36 36
 				);
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 
41 41
 				// Dispatch to own process group.
42 42
 				$pgid = posix_getpgid(getmypid());
43
-				if ($pgid<=0) {
43
+				if ($pgid <= 0) {
44 44
 					echo sprintf(
45
-						'[-] Unable to send signal to invalid PGID "%s".' . PHP_EOL,
45
+						'[-] Unable to send signal to invalid PGID "%s".'.PHP_EOL,
46 46
 						$pgid
47 47
 					);
48 48
 				} else {
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 		// to this job as a whole (including any subprocesses such as spawned by Symfony).
61 61
 		posix_setsid();
62 62
 
63
-		if(function_exists('pcntl_alarm') && function_exists('pcntl_signal')) {
63
+		if (function_exists('pcntl_alarm') && function_exists('pcntl_signal')) {
64 64
 			if (!empty($this->args['sigFile'])) {
65
-				echo sprintf('[-] Signal file requested, polling "%s".' . PHP_EOL, $this->args['sigFile']);
65
+				echo sprintf('[-] Signal file requested, polling "%s".'.PHP_EOL, $this->args['sigFile']);
66 66
 				declare(ticks = 1);
67 67
 				pcntl_signal(SIGALRM, [$this, 'alarmHandler']);
68 68
 				pcntl_alarm(1);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	public function perform() {
77
-		echo "[-] DeployJob starting" . PHP_EOL;
77
+		echo "[-] DeployJob starting".PHP_EOL;
78 78
 		$log = new DeploynautLogFile($this->args['logfile']);
79 79
 
80 80
 		$deployment = DNDeployment::get()->byID($this->args['deploymentID']);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		// deploy onto a clean environment will not be performing any backup regardless of
93 93
 		// whether the predeploy_backup option was passed or not.
94 94
 		// Sometimes predeploy_backup comes through as string false from the frontend.
95
-		if(
95
+		if (
96 96
 			!empty($this->args['predeploy_backup'])
97 97
 			&& $this->args['predeploy_backup'] !== 'false'
98 98
 			&& !empty($currentBuild)
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 			// Disallow concurrent deployments (don't rely on queuing implementation to restrict this)
115 115
 			// Only consider deployments started in the last 30 minutes (older jobs probably got stuck)
116 116
 			$runningDeployments = $environment->runningDeployments()->exclude('ID', $this->args['deploymentID']);
117
-			if($runningDeployments->count()) {
117
+			if ($runningDeployments->count()) {
118 118
 				$runningDeployment = $runningDeployments->first();
119 119
 				$message = sprintf(
120 120
 					'Error: another deployment is in progress (started at %s by %s)',
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 				// all options from the DeploymentStrategy merged in, including sha.
135 135
 				$this->args
136 136
 			);
137
-		} catch(Exception $e) {
137
+		} catch (Exception $e) {
138 138
 			// DeploynautJob will automatically trigger onFailure.
139
-			echo "[-] DeployJob failed" . PHP_EOL;
139
+			echo "[-] DeployJob failed".PHP_EOL;
140 140
 			throw $e;
141 141
 		}
142 142
 
143 143
 		$this->updateStatus(DNDeployment::TR_COMPLETE);
144
-		echo "[-] DeployJob finished" . PHP_EOL;
144
+		echo "[-] DeployJob finished".PHP_EOL;
145 145
 	}
146 146
 
147 147
 	public function onFailure(Exception $exception) {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			DB::connect($databaseConfig);
161 161
 			$backupDataTransfer->Status = 'Finished';
162 162
 			$backupDataTransfer->write();
163
-		} catch(Exception $e) {
163
+		} catch (Exception $e) {
164 164
 			global $databaseConfig;
165 165
 			DB::connect($databaseConfig);
166 166
 			$backupDataTransfer->Status = 'Failed';
Please login to merge, or discard this patch.
code/control/DeploynautLogFile.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @return string
46 46
 	 */
47 47
 	public function getRawFilePath() {
48
-		return $this->basePath . '/' . $this->logFile;
48
+		return $this->basePath.'/'.$this->logFile;
49 49
 	}
50 50
 
51 51
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return string
54 54
 	 */
55 55
 	public function getSanitisedLogFilePath() {
56
-		return $this->basePath . '/' . strtolower(FileNameFilter::create()->filter($this->logFile));
56
+		return $this->basePath.'/'.strtolower(FileNameFilter::create()->filter($this->logFile));
57 57
 	}
58 58
 
59 59
 	/**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		// Make sure we write into the old path for existing logs. New logs use the sanitised file path instead.
84 84
 		$path = file_exists($this->getRawFilePath()) ? $this->getRawFilePath() : $this->getSanitisedLogFilePath();
85 85
 
86
-		error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $path);
86
+		error_log('['.date('Y-m-d H:i:s').'] '.$message.PHP_EOL, 3, $path);
87 87
 		@chmod($path, 0666);
88 88
 	}
89 89
 
Please login to merge, or discard this patch.
code/tasks/SyncProjectsAndEnvironments.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@  discard block
 block discarded – undo
9 9
 		$remove = true;
10 10
 		$dryRun = true;
11 11
 
12
-		if($request && $request->requestVar('remove') !== null) {
13
-			$remove = (bool)$request->requestVar('remove');
12
+		if ($request && $request->requestVar('remove') !== null) {
13
+			$remove = (bool) $request->requestVar('remove');
14 14
 		}
15 15
 
16
-		if($request && $request->requestVar('dryrun') !== null) {
17
-			$dryRun = (bool)$request->requestVar('dryrun');
16
+		if ($request && $request->requestVar('dryrun') !== null) {
17
+			$dryRun = (bool) $request->requestVar('dryrun');
18 18
 		}
19 19
 
20
-		if($dryRun) {
20
+		if ($dryRun) {
21 21
 			echo "Running in dry run mode, no changes commited, ";
22
-			echo "the output shows a prediction on what will happen." . PHP_EOL;
23
-			echo "To skip dryrun, run the task like this:" . PHP_EOL;
24
-			echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0" . PHP_EOL . PHP_EOL;
22
+			echo "the output shows a prediction on what will happen.".PHP_EOL;
23
+			echo "To skip dryrun, run the task like this:".PHP_EOL;
24
+			echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0".PHP_EOL.PHP_EOL;
25 25
 			sleep(3);
26 26
 		}
27 27
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 		// Sync projects
32 32
 		$projects = DNProject::get();
33
-		if($remove) {
33
+		if ($remove) {
34 34
 			$this->echoHeader('Removing obsolete projects');
35 35
 			$this->removeObsoleteProjects($projectPaths, $dryRun);
36 36
 		}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		$this->syncProjectPaths($projectPaths, $dryRun);
39 39
 
40 40
 		$this->echoHeader('Syncing environment files');
41
-		foreach($projects as $project) {
41
+		foreach ($projects as $project) {
42 42
 			$this->echoHeader($project->Name);
43 43
 			// Sync environments for each project
44 44
 			$environmentPaths = $data->getEnvironmentPaths($project->Name);
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 		}, $paths);
63 63
 
64 64
 		$removeList = $list->filter('Filename:not', $basePaths);
65
-		if($removeList->count() === 0) {
65
+		if ($removeList->count() === 0) {
66 66
 			return;
67 67
 		}
68 68
 
69
-		foreach($removeList as $remove) {
70
-			$this->message('Removing "' . basename($remove->Name) . '" from db');
71
-			if(!$dryRun) {
69
+		foreach ($removeList as $remove) {
70
+			$this->message('Removing "'.basename($remove->Name).'" from db');
71
+			if (!$dryRun) {
72 72
 				$removeList->remove($remove);
73 73
 			}
74 74
 		}
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	protected function removeObsoleteProjects($paths, $dryrun = false) {
85 85
 		$removeList = DNProject::get()->filter('Name:not', $paths);
86
-		if($removeList->count() == 0) {
86
+		if ($removeList->count() == 0) {
87 87
 			return;
88 88
 		}
89 89
 
90
-		foreach($removeList as $remove) {
91
-			$this->message($remove->Name . ' ' . $remove->Path);
92
-			if(!$dryrun) {
90
+		foreach ($removeList as $remove) {
91
+			$this->message($remove->Name.' '.$remove->Path);
92
+			if (!$dryrun) {
93 93
 				$removeList->remove($remove);
94 94
 			}
95 95
 		}
@@ -106,22 +106,22 @@  discard block
 block discarded – undo
106 106
 		$list = $project->Environments();
107 107
 
108 108
 		// Normalise paths in DB
109
-		foreach($list as $item) {
109
+		foreach ($list as $item) {
110 110
 			$real = realpath($item->Filename);
111
-			if($real && $real != $item->Filename) {
111
+			if ($real && $real != $item->Filename) {
112 112
 				$item->Filename = $real;
113 113
 				$item->write();
114 114
 			}
115 115
 		}
116 116
 
117
-		foreach($paths as $path) {
117
+		foreach ($paths as $path) {
118 118
 			$path = basename($path);
119
-			if($list->filter('Filename', $path)->count()) {
119
+			if ($list->filter('Filename', $path)->count()) {
120 120
 				continue;
121 121
 			}
122 122
 
123
-			$this->message('Adding "' . basename($path) . '" to db');
124
-			if(!$dryRun) {
123
+			$this->message('Adding "'.basename($path).'" to db');
124
+			if (!$dryRun) {
125 125
 				$environment = DNEnvironment::create_from_path($path);
126 126
 				$environment->ProjectID = $project->ID;
127 127
 				$environment->write();
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
 	 * @param boolean $dryRun
137 137
 	 */
138 138
 	public function syncProjectPaths($paths, $dryRun = false) {
139
-		foreach($paths as $path) {
140
-			if(!DNProject::get()->filter('Name', $path)->count()) {
139
+		foreach ($paths as $path) {
140
+			if (!DNProject::get()->filter('Name', $path)->count()) {
141 141
 				$this->message($path);
142
-				if(!$dryRun) {
142
+				if (!$dryRun) {
143 143
 					DNProject::create_from_path($path)->write();
144 144
 				}
145 145
 			}
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 	 * @param string $text
151 151
 	 */
152 152
 	protected function message($text) {
153
-		if(PHP_SAPI !== 'cli') {
154
-			$text = '<p>' . $text . '</p>' . PHP_EOL;
153
+		if (PHP_SAPI !== 'cli') {
154
+			$text = '<p>'.$text.'</p>'.PHP_EOL;
155 155
 		}
156
-		echo ' - ' . $text . PHP_EOL;
156
+		echo ' - '.$text.PHP_EOL;
157 157
 	}
158 158
 
159 159
 	/**
160 160
 	 * @param string $text
161 161
 	 */
162 162
 	protected function echoHeader($text) {
163
-		if(PHP_SAPI !== 'cli') {
164
-			echo '<h2>' . $text . '</h2>' . PHP_EOL;
163
+		if (PHP_SAPI !== 'cli') {
164
+			echo '<h2>'.$text.'</h2>'.PHP_EOL;
165 165
 		} else {
166
-			echo '# ' . $text . PHP_EOL;
166
+			echo '# '.$text.PHP_EOL;
167 167
 		}
168 168
 	}
169 169
 }
Please login to merge, or discard this patch.
code/model/DNEnvironment.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 				->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members)
775 775
 				->setTitle('Who can upload?')
776 776
 				->setDescription(
777
-					'Users who can upload archives linked to this environment into Deploynaut.<br />' .
777
+					'Users who can upload archives linked to this environment into Deploynaut.<br />'.
778 778
 					'Linking them to an environment allows limiting download permissions (see below).'
779 779
 				),
780 780
 
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 		// Add actions
822 822
 		$action = new FormAction('check', 'Check Connection');
823 823
 		$action->setUseButtonTag(true);
824
-		$dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping';
824
+		$dataURL = Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping';
825 825
 		$action->setAttribute('data-url', $dataURL);
826 826
 		$fields->insertBefore($action, 'Name');
827 827
 
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
 	 */
835 835
 	public function onBeforeWrite() {
836 836
 		parent::onBeforeWrite();
837
-		if ($this->Name && $this->Name . '.rb' != $this->Filename) {
838
-			$this->Filename = $this->Name . '.rb';
837
+		if ($this->Name && $this->Name.'.rb' != $this->Filename) {
838
+			$this->Filename = $this->Name.'.rb';
839 839
 		}
840 840
 		$this->checkEnvironmentPath();
841 841
 		$this->writeConfigFile();
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 		if (!$this->Filename) {
886 886
 			return '';
887 887
 		}
888
-		return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename;
888
+		return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename;
889 889
 	}
890 890
 
891 891
 	/**
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 			&& $this->Filename
1040 1040
 			&& $this->CreateEnvConfig
1041 1041
 		) {
1042
-			$templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template';
1042
+			$templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template';
1043 1043
 			file_put_contents($this->getConfigFilename(), file_get_contents($templateFile));
1044 1044
 		} else if ($this->envFileExists() && $this->DeployConfig) {
1045 1045
 			file_put_contents($this->getConfigFilename(), $this->DeployConfig);
Please login to merge, or discard this patch.
code/model/DNBranch.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
 	 * @return string
51 51
 	 */
52 52
 	public function Name() {
53
-		return (string)htmlentities($this->branch->getName());
53
+		return (string) htmlentities($this->branch->getName());
54 54
 	}
55 55
 
56 56
 	public function Link() {
57 57
 		// Use a get-var for branch so that it can handle unsafe chars better
58
-		return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name()));
58
+		return Controller::join_links($this->project->Link(), 'branch?name='.urlencode($this->Name()));
59 59
 	}
60 60
 
61 61
 	/**
62 62
 	 * @return string
63 63
 	 */
64 64
 	public function SHA() {
65
-		return (string)htmlentities($this->branch->getCommit()->getHash());
65
+		return (string) htmlentities($this->branch->getCommit()->getHash());
66 66
 	}
67 67
 
68 68
 	/**
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function LastUpdated() {
80 80
 
81
-		if($this->_lastUpdatedCache) {
81
+		if ($this->_lastUpdatedCache) {
82 82
 			return $this->_lastUpdatedCache;
83 83
 		}
84 84
 		try {
85 85
 			$created = $this->branch->getCommit()->getCommitterDate();
86
-		} catch(Exception $e) {
86
+		} catch (Exception $e) {
87 87
 			//occasionally parsing will fail this is a fallback to make it still work
88 88
 			return new SS_Datetime();
89 89
 		}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @return string
104 104
 	 */
105 105
 	public function IsOpenByDefault() {
106
-		if($this->Name() == 'master') {
106
+		if ($this->Name() == 'master') {
107 107
 			return " open";
108 108
 		} else {
109 109
 			return "";
Please login to merge, or discard this patch.
code/backends/CapistranoDeploymentBackend.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 		$currentBuild = $environment->CurrentBuild();
27 27
 		$currentSha = $currentBuild ? $currentBuild->SHA : '-';
28
-		if($currentSha !== $options['sha']) {
28
+		if ($currentSha !== $options['sha']) {
29 29
 			$strategy->setChange('Code version', $currentSha, $options['sha']);
30 30
 		}
31 31
 		$strategy->setActionTitle('Confirm deployment');
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 		// Use a package generator if specified, otherwise run a direct deploy, which is the default behaviour
68 68
 		// if build_filename isn't specified
69
-		if($this->packageGenerator) {
69
+		if ($this->packageGenerator) {
70 70
 			$log->write(sprintf('Using package generator "%s"', get_class($this->packageGenerator)));
71 71
 
72 72
 			try {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 				throw $e;
77 77
 			}
78 78
 
79
-			if(empty($args['build_filename'])) {
79
+			if (empty($args['build_filename'])) {
80 80
 				throw new RuntimeException('Failed to generate package.');
81 81
 			}
82 82
 		}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 				$log->write($buffer);
95 95
 			});
96 96
 
97
-			if(!$command->isSuccessful()) {
97
+			if (!$command->isSuccessful()) {
98 98
 				$self->extend('cleanupFailure', $environment, $sha, $log, $project);
99 99
 				$log->write('Warning: Cleanup failed, but fine to continue. Needs manual cleanup sometime.');
100 100
 			}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$this->enableMaintenance($environment, $log, $project);
106 106
 
107 107
 		$rolledBack = null;
108
-		if(!$command->isSuccessful() || !$this->smokeTest($environment, $log)) {
108
+		if (!$command->isSuccessful() || !$this->smokeTest($environment, $log)) {
109 109
 			$cleanupFn();
110 110
 			$this->extend('deployFailure', $environment, $sha, $log, $project);
111 111
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		$command->run(function($type, $buffer) use($log) {
172 172
 			$log->write($buffer);
173 173
 		});
174
-		if(!$command->isSuccessful()) {
174
+		if (!$command->isSuccessful()) {
175 175
 			$this->extend('maintenanceEnableFailure', $environment, $log);
176 176
 			throw new RuntimeException($command->getErrorOutput());
177 177
 		}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		$command->run(function($type, $buffer) use($log) {
188 188
 			$log->write($buffer);
189 189
 		});
190
-		if(!$command->isSuccessful()) {
190
+		if (!$command->isSuccessful()) {
191 191
 			$this->extend('maintenanceDisableFailure', $environment, $log);
192 192
 			throw new RuntimeException($command->getErrorOutput());
193 193
 		}
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 	 * @inheritdoc
210 210
 	 */
211 211
 	public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log) {
212
-		if($dataTransfer->Direction == 'get') {
212
+		if ($dataTransfer->Direction == 'get') {
213 213
 			$this->dataTransferBackup($dataTransfer, $log);
214 214
 		} else {
215 215
 			$environment = $dataTransfer->Environment();
216 216
 			$project = $environment->Project();
217
-			$workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID;
217
+			$workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID;
218 218
 			$archive = $dataTransfer->DataArchive();
219 219
 
220 220
 			// extract the sspak contents, we'll need these so capistrano can restore that content
221 221
 			try {
222 222
 				$archive->extractArchive($workingDir);
223
-			} catch(Exception $e) {
223
+			} catch (Exception $e) {
224 224
 				$log->write($e->getMessage());
225 225
 				throw new RuntimeException($e->getMessage());
226 226
 			}
227 227
 
228 228
 			// validate the contents match the requested transfer mode
229 229
 			$result = $archive->validateArchiveContents($dataTransfer->Mode);
230
-			if(!$result->valid()) {
230
+			if (!$result->valid()) {
231 231
 				// do some cleaning, get rid of the extracted archive lying around
232 232
 				$process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir)));
233 233
 				$process->setTimeout(120);
@@ -257,41 +257,41 @@  discard block
 block discarded – undo
257 257
 		$name = $environment->getFullName();
258 258
 		$env = $environment->Project()->getProcessEnv();
259 259
 
260
-		if(!$args) {
260
+		if (!$args) {
261 261
 			$args = array();
262 262
 		}
263
-		$args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/');
263
+		$args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/');
264 264
 		$args['environment_id'] = $environment->ID;
265 265
 
266 266
 		// Inject env string directly into the command.
267 267
 		// Capistrano doesn't like the $process->setEnv($env) we'd normally do below.
268 268
 		$envString = '';
269
-		if(!empty($env)) {
269
+		if (!empty($env)) {
270 270
 			$envString .= 'env ';
271
-			foreach($env as $key => $value) {
271
+			foreach ($env as $key => $value) {
272 272
 				$envString .= "$key=\"$value\" ";
273 273
 			}
274 274
 		}
275 275
 
276 276
 		$data = DNData::inst();
277 277
 		// Generate a capfile from a template
278
-		$capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template');
278
+		$capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template');
279 279
 		$cap = str_replace(
280 280
 			array('<config root>', '<ssh key>', '<base path>'),
281 281
 			array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH),
282 282
 			$capTemplate
283 283
 		);
284 284
 
285
-		if(defined('DEPLOYNAUT_CAPFILE')) {
285
+		if (defined('DEPLOYNAUT_CAPFILE')) {
286 286
 			$capFile = DEPLOYNAUT_CAPFILE;
287 287
 		} else {
288
-			$capFile = ASSETS_PATH . '/Capfile';
288
+			$capFile = ASSETS_PATH.'/Capfile';
289 289
 		}
290 290
 		file_put_contents($capFile, $cap);
291 291
 
292
-		$command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles";
293
-		foreach($args as $argName => $argVal) {
294
-			$command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal);
292
+		$command = "{$envString}cap -f ".escapeshellarg($capFile)." -vv $name $action ROLES=$roles";
293
+		foreach ($args as $argName => $argVal) {
294
+			$command .= ' -s '.escapeshellarg($argName).'='.escapeshellarg($argVal);
295 295
 		}
296 296
 
297 297
 		$log->write(sprintf('Running command: %s', $command));
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
 		$filepathBase = $dataArchive->generateFilepath($dataTransfer);
326 326
 		mkdir($filepathBase, 0700, true);
327 327
 
328
-		$databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql.gz';
328
+		$databasePath = $filepathBase.DIRECTORY_SEPARATOR.'database.sql.gz';
329 329
 
330 330
 		// Backup database
331
-		if(in_array($dataTransfer->Mode, array('all', 'db'))) {
331
+		if (in_array($dataTransfer->Mode, array('all', 'db'))) {
332 332
 			$log->write(sprintf('Backup of database from "%s" started', $name));
333 333
 			$command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $log);
334 334
 			$command->run(function($type, $buffer) use($log) {
335 335
 				$log->write($buffer);
336 336
 			});
337
-			if(!$command->isSuccessful()) {
337
+			if (!$command->isSuccessful()) {
338 338
 				$this->extend('dataTransferFailure', $environment, $log);
339 339
 				throw new RuntimeException($command->getErrorOutput());
340 340
 			}
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
 		}
343 343
 
344 344
 		// Backup assets
345
-		if(in_array($dataTransfer->Mode, array('all', 'assets'))) {
345
+		if (in_array($dataTransfer->Mode, array('all', 'assets'))) {
346 346
 			$log->write(sprintf('Backup of assets from "%s" started', $name));
347 347
 			$command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log);
348 348
 			$command->run(function($type, $buffer) use($log) {
349 349
 				$log->write($buffer);
350 350
 			});
351
-			if(!$command->isSuccessful()) {
351
+			if (!$command->isSuccessful()) {
352 352
 				$this->extend('dataTransferFailure', $environment, $log);
353 353
 				throw new RuntimeException($command->getErrorOutput());
354 354
 			}
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
 		$log->write('Creating sspak...');
364 364
 
365 365
 		$sspakFilename = sprintf('%s.sspak', $dataArchive->generateFilename($dataTransfer));
366
-		$sspakFilepath = $filepathBase . DIRECTORY_SEPARATOR . $sspakFilename;
366
+		$sspakFilepath = $filepathBase.DIRECTORY_SEPARATOR.$sspakFilename;
367 367
 
368 368
 		try {
369 369
 			$dataArchive->attachFile($sspakFilepath, $dataTransfer);
370 370
 			$dataArchive->setArchiveFromFiles($filepathBase);
371
-		} catch(Exception $e) {
371
+		} catch (Exception $e) {
372 372
 			$log->write($e->getMessage());
373 373
 			throw new RuntimeException($e->getMessage());
374 374
 		}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		$process = new AbortableProcess(sprintf('rm -rf %s/assets && rm -f %s', escapeshellarg($filepathBase), escapeshellarg($databasePath)));
380 380
 		$process->setTimeout(120);
381 381
 		$process->run();
382
-		if(!$process->isSuccessful()) {
382
+		if (!$process->isSuccessful()) {
383 383
 			$log->write('Could not delete temporary files');
384 384
 			throw new RuntimeException($process->getErrorOutput());
385 385
 		}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 		$command->run(function($type, $buffer) use($log) {
399 399
 			$log->write($buffer);
400 400
 		});
401
-		if(!$command->isSuccessful()) {
401
+		if (!$command->isSuccessful()) {
402 402
 			$log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput()));
403 403
 			throw new RuntimeException($command->getErrorOutput());
404 404
 		}
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
 		};
429 429
 
430 430
 		// Restore database into target environment
431
-		if(in_array($dataTransfer->Mode, array('all', 'db'))) {
431
+		if (in_array($dataTransfer->Mode, array('all', 'db'))) {
432 432
 			$log->write(sprintf('Restore of database to "%s" started', $name));
433
-			$args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql');
433
+			$args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'database.sql');
434 434
 			$command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log);
435 435
 			$command->run(function($type, $buffer) use($log) {
436 436
 				$log->write($buffer);
437 437
 			});
438
-			if(!$command->isSuccessful()) {
438
+			if (!$command->isSuccessful()) {
439 439
 				$cleanupFn();
440 440
 				$log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput()));
441 441
 				$this->extend('dataTransferFailure', $environment, $log);
@@ -445,14 +445,14 @@  discard block
 block discarded – undo
445 445
 		}
446 446
 
447 447
 		// Restore assets into target environment
448
-		if(in_array($dataTransfer->Mode, array('all', 'assets'))) {
448
+		if (in_array($dataTransfer->Mode, array('all', 'assets'))) {
449 449
 			$log->write(sprintf('Restore of assets to "%s" started', $name));
450
-			$args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets');
450
+			$args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'assets');
451 451
 			$command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log);
452 452
 			$command->run(function($type, $buffer) use($log) {
453 453
 				$log->write($buffer);
454 454
 			});
455
-			if(!$command->isSuccessful()) {
455
+			if (!$command->isSuccessful()) {
456 456
 				$cleanupFn();
457 457
 				$log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput()));
458 458
 				$this->extend('dataTransferFailure', $environment, $log);
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		$timeout = 600;
478 478
 		$tick = 60;
479 479
 
480
-		if(!$url) {
480
+		if (!$url) {
481 481
 			$log->write('Skipping site accessible check: no URL found.');
482 482
 			return true;
483 483
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		// query the site every second. Note that if the URL doesn't respond,
509 509
 		// curl_exec will take 5 seconds to timeout (see CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT above)
510 510
 		do {
511
-			if(time() > $start + $timeout) {
511
+			if (time() > $start + $timeout) {
512 512
 				$log->write(sprintf(' * Failed: check for %s timed out after %smin', $url, $timeout / 60));
513 513
 				return false;
514 514
 			}
@@ -517,13 +517,13 @@  discard block
 block discarded – undo
517 517
 
518 518
 			// check the HTTP response code for HTTP protocols
519 519
 			$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
520
-			if($status && !in_array($status, [500, 501, 502, 503, 504])) {
520
+			if ($status && !in_array($status, [500, 501, 502, 503, 504])) {
521 521
 				$success = true;
522 522
 			}
523 523
 
524 524
 			// check for any curl errors, mostly for checking the response state of non-HTTP protocols,
525 525
 			// but applies to checks of any protocol
526
-			if($response && !curl_errno($ch)) {
526
+			if ($response && !curl_errno($ch)) {
527 527
 				$success = true;
528 528
 			}
529 529
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 			}
552 552
 
553 553
 			sleep(1);
554
-		} while(!$success);
554
+		} while (!$success);
555 555
 
556 556
 		curl_close($ch);
557 557
 		$log->write(' * Success: site is accessible!');
Please login to merge, or discard this patch.