Completed
Pull Request — master (#63)
by Andrew
01:28
created
src/sspak-sniffer.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@
 block discarded – undo
13 13
 }
14 14
 
15 15
 $basePath = $_SERVER['argv'][1];
16
-if($basePath[0] != '/') $basePath = getcwd() . '/' . $basePath;
16
+if($basePath[0] != '/') {
17
+	$basePath = getcwd() . '/' . $basePath;
18
+}
17 19
 
18 20
 // SilverStripe bootstrap
19 21
 define('BASE_PATH', $basePath);
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Argument parsing
10
-if(empty($_SERVER['argv'][1])) {
10
+if (empty($_SERVER['argv'][1])) {
11 11
 	echo "Usage: {$_SERVER['argv'][0]} (site-docroot)\n";
12 12
 	exit(1);
13 13
 }
14 14
 
15 15
 $basePath = $_SERVER['argv'][1];
16
-if($basePath[0] != '/') $basePath = getcwd() . '/' . $basePath;
16
+if ($basePath[0] != '/') $basePath = getcwd().'/'.$basePath;
17 17
 
18 18
 // SilverStripe bootstrap
19 19
 define('BASE_PATH', $basePath);
@@ -23,24 +23,24 @@  discard block
 block discarded – undo
23 23
 $_SERVER['HTTP_HOST'] = 'localhost';
24 24
 chdir(BASE_PATH);
25 25
 
26
-if(file_exists(BASE_PATH.'/sapphire/core/Core.php')) {
26
+if (file_exists(BASE_PATH.'/sapphire/core/Core.php')) {
27 27
 	//SS 2.x
28
-	require_once(BASE_PATH . '/sapphire/core/Core.php');
29
-} else if(file_exists(BASE_PATH.'/framework/core/Core.php')) {
28
+	require_once(BASE_PATH.'/sapphire/core/Core.php');
29
+} else if (file_exists(BASE_PATH.'/framework/core/Core.php')) {
30 30
 	//SS 3.x
31
-	require_once(BASE_PATH. '/framework/core/Core.php');
32
-} else if(file_exists(BASE_PATH.'/framework/src/Core/Core.php')) {
31
+	require_once(BASE_PATH.'/framework/core/Core.php');
32
+} else if (file_exists(BASE_PATH.'/framework/src/Core/Core.php')) {
33 33
 	//SS 4.x
34
-	require_once(BASE_PATH. '/vendor/autoload.php');
35
-	require_once(BASE_PATH. '/framework/src/Core/Core.php');
34
+	require_once(BASE_PATH.'/vendor/autoload.php');
35
+	require_once(BASE_PATH.'/framework/src/Core/Core.php');
36 36
 } else {
37
-	echo "Couldn't locate framework's Core.php. Perhaps " . BASE_PATH . " is not a SilverStripe project?\n";
37
+	echo "Couldn't locate framework's Core.php. Perhaps ".BASE_PATH." is not a SilverStripe project?\n";
38 38
 	exit(2);
39 39
 }
40 40
 
41 41
 $output = array();
42
-foreach($databaseConfig as $k => $v) {
43
-	$output['db_' . $k] = $v;
42
+foreach ($databaseConfig as $k => $v) {
43
+	$output['db_'.$k] = $v;
44 44
 }
45 45
 $output['assets_path'] = ASSETS_PATH;
46 46
 
Please login to merge, or discard this patch.
src/DataExtractor/CsvTableWriter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 
34 34
 	private function mapFromColumns($record) {
35 35
 		$row = [];
36
-		foreach($this->columns as $i => $column)
36
+		foreach ($this->columns as $i => $column)
37 37
 		{
38 38
 			$row[$i] = isset($record[$column]) ? $record[$column] : null;
39 39
 		}
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -9,6 +9,9 @@
 block discarded – undo
9 9
 	private $handle;
10 10
 	private $columns;
11 11
 
12
+	/**
13
+	 * @param string $filename
14
+	 */
12 15
 	public function __construct($filename) {
13 16
 		$this->filename = $filename;
14 17
 	}
Please login to merge, or discard this patch.
src/DataExtractor/CsvTableReader.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		$this->columns = null;
25 25
 		$this->initColumns();
26 26
 
27
-		while(($row = $this->getRow()) !== false) {
27
+		while (($row = $this->getRow()) !== false) {
28 28
 			yield $this->mapToColumns($row);
29 29
 		}
30 30
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 
34 34
 	private function mapToColumns($row) {
35 35
 		$record = [];
36
-		foreach($row as $i => $value)
36
+		foreach ($row as $i => $value)
37 37
 		{
38
-			if(isset($this->columns[$i])) {
38
+			if (isset($this->columns[$i])) {
39 39
 				$record[$this->columns[$i]] = $value;
40 40
 			} else {
41
-				throw new \LogicException("Row contains invalid column #$i\n" . var_export($row, true));
41
+				throw new \LogicException("Row contains invalid column #$i\n".var_export($row, true));
42 42
 			}
43 43
 		}
44 44
 		return $record;
Please login to merge, or discard this patch.
tests/DataExtractor/CsvTableWriterTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 		$csv = new CsvTableWriter('/tmp/output.csv');
14 14
 
15 15
 		$csv->start(['Col1', 'Col2', 'Col3']);
16
-		$csv->writeRecord([ 'Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three' ]);
17
-		$csv->writeRecord([ 'Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?" ]);
16
+		$csv->writeRecord(['Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three']);
17
+		$csv->writeRecord(['Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?"]);
18 18
 		$csv->finish();
19 19
 
20 20
 		$csvContent = file_get_contents('/tmp/output.csv');
21 21
 		unlink('/tmp/output.csv');
22 22
 
23
-		$fixture = file_get_contents(__DIR__ . '/fixture/input.csv');
23
+		$fixture = file_get_contents(__DIR__.'/fixture/input.csv');
24 24
 
25 25
 		$this->assertEquals($fixture, $csvContent);
26 26
 	}
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 
34 34
 		$csv = new CsvTableWriter('/tmp/output.csv');
35 35
 
36
-		$csv->writeRecord([ 'Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three' ]);
37
-		$csv->writeRecord([ 'Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?" ]);
36
+		$csv->writeRecord(['Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three']);
37
+		$csv->writeRecord(['Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?"]);
38 38
 		$csv->finish();
39 39
 
40 40
 		$csvContent = file_get_contents('/tmp/output.csv');
41 41
 		unlink('/tmp/output.csv');
42 42
 
43
-		$fixture = file_get_contents(__DIR__ . '/fixture/input.csv');
43
+		$fixture = file_get_contents(__DIR__.'/fixture/input.csv');
44 44
 
45 45
 		$this->assertEquals($fixture, $csvContent);
46 46
 	}
Please login to merge, or discard this patch.
tests/SmokeTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('PACKAGE_ROOT' , dirname(__DIR__).'/');
4
-require_once(PACKAGE_ROOT . 'src/SSPak.php');
3
+define('PACKAGE_ROOT', dirname(__DIR__).'/');
4
+require_once(PACKAGE_ROOT.'src/SSPak.php');
5 5
 
6 6
 /**
7 7
  * Confirm that the compile binary executes
Please login to merge, or discard this patch.
src/Executor.php 3 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -18,9 +18,6 @@
 block discarded – undo
18 18
 
19 19
 	/**
20 20
 	 * @param string $command The command
21
-	 * @param boolean $throwException If true, an Exception will be thrown on a nonzero error code
22
-	 * @param boolean $returnOutput If true, output will be captured
23
-	 * @param boolean $inputContent Content for STDIN. Otherwise the parent script's STDIN is used
24 21
 	 * @return A map containing 'return', 'output', and 'error'
25 22
 	 */
26 23
 	public function execLocal($command, $options = array()) {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 	public function createLocal($command, $options) {
37 37
 		$options = array_merge($this->defaultOptions, $options);
38
-		if(is_array($command)) $command = $this->commandArrayToString($command);
38
+		if (is_array($command)) $command = $this->commandArrayToString($command);
39 39
 
40 40
 		return new Process($command, $options);
41 41
 	}
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function commandArrayToString($command) {
55 55
 		$string = escapeshellcmd(array_shift($command));
56
-		foreach($command as $arg) {
57
-			$string .= ' ' . escapeshellarg($arg);
56
+		foreach ($command as $arg) {
57
+			$string .= ' '.escapeshellarg($arg);
58 58
 		}
59 59
 		return $string;
60 60
 	}
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 		$options = array_merge($this->options, $options);
81 81
 
82 82
 		// Modify command for remote execution, if necessary.
83
-		if($this->remoteServer) {
84
-			if(!empty($options['outputFile']) || !empty($options['outputStream'])) $ssh = "ssh -T ";
83
+		if ($this->remoteServer) {
84
+			if (!empty($options['outputFile']) || !empty($options['outputStream'])) $ssh = "ssh -T ";
85 85
 			else $ssh = "ssh -t ";
86 86
 			if (!empty($options['identity'])) {
87
-				$ssh .= '-i ' . escapeshellarg($options['identity']) . ' ';
87
+				$ssh .= '-i '.escapeshellarg($options['identity']).' ';
88 88
 			}
89
-			$command = $ssh . escapeshellarg($this->remoteServer) . ' ' . escapeshellarg($this->command);
89
+			$command = $ssh.escapeshellarg($this->remoteServer).' '.escapeshellarg($this->command);
90 90
 		} else {
91 91
 			$command = $this->command;
92 92
 		}
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 		);
100 100
 
101 101
 		// Alternatives
102
-		if($options['inputContent'] || $options['inputStream']) $pipeSpec[0] = array('pipe', 'r');
102
+		if ($options['inputContent'] || $options['inputStream']) $pipeSpec[0] = array('pipe', 'r');
103 103
 
104
-		if($options['outputFile']) {
104
+		if ($options['outputFile']) {
105 105
 			$pipeSpec[1] = array('file',
106 106
 				$options['outputFile'],
107 107
 				$options['outputFileAppend'] ? 'a' : 'w');
@@ -109,24 +109,24 @@  discard block
 block discarded – undo
109 109
 
110 110
 		$process = proc_open($command, $pipeSpec, $pipes);
111 111
 
112
-		if($options['inputContent']) {
112
+		if ($options['inputContent']) {
113 113
 			fwrite($pipes[0], $options['inputContent']);
114 114
 
115
-		} else if($options['inputStream']) {
116
-			while($content = fread($options['inputStream'], 8192)) {
115
+		} else if ($options['inputStream']) {
116
+			while ($content = fread($options['inputStream'], 8192)) {
117 117
 				fwrite($pipes[0], $content);
118 118
 			}
119 119
 		}
120
-		if(isset($pipes[0])) fclose($pipes[0]);
120
+		if (isset($pipes[0])) fclose($pipes[0]);
121 121
 
122 122
 		$result = array();
123 123
 
124
-		if(isset($pipes[1])) {
124
+		if (isset($pipes[1])) {
125 125
 			// If a stream was provided, then pipe all the content
126 126
 			// Doing it this way rather than passing outputStream to $pipeSpec
127 127
 			// Means that streams as well as simple FDs can be used
128
-			if($options['outputStream']) {
129
-				while($content = fread($pipes[1], 8192)) {
128
+			if ($options['outputStream']) {
129
+				while ($content = fread($pipes[1], 8192)) {
130 130
 					fwrite($options['outputStream'], $content);
131 131
 				}
132 132
 
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 			}
137 137
 			fclose($pipes[1]);
138 138
 		}
139
-		if(isset($pipes[2])) {
139
+		if (isset($pipes[2])) {
140 140
 			$result['error'] = stream_get_contents($pipes[2]);
141 141
 			fclose($pipes[2]);
142 142
 		}
143 143
 
144 144
 		$result['return'] = proc_close($process);
145 145
 
146
-		if($options['throwException'] && $result['return'] != 0)	{
146
+		if ($options['throwException'] && $result['return'] != 0) {
147 147
 			throw new Exception("Command: $command\nExecution failed: returned {$result['return']}.\n"
148 148
 				. (empty($result['output']) ? "" : "Output:\n{$result['output']}"));
149 149
 		}
Please login to merge, or discard this patch.
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 
36 36
 	public function createLocal($command, $options) {
37 37
 		$options = array_merge($this->defaultOptions, $options);
38
-		if(is_array($command)) $command = $this->commandArrayToString($command);
38
+		if(is_array($command)) {
39
+			$command = $this->commandArrayToString($command);
40
+		}
39 41
 
40 42
 		return new Process($command, $options);
41 43
 	}
@@ -81,8 +83,11 @@  discard block
 block discarded – undo
81 83
 
82 84
 		// Modify command for remote execution, if necessary.
83 85
 		if($this->remoteServer) {
84
-			if(!empty($options['outputFile']) || !empty($options['outputStream'])) $ssh = "ssh -T ";
85
-			else $ssh = "ssh -t ";
86
+			if(!empty($options['outputFile']) || !empty($options['outputStream'])) {
87
+				$ssh = "ssh -T ";
88
+			} else {
89
+				$ssh = "ssh -t ";
90
+			}
86 91
 			if (!empty($options['identity'])) {
87 92
 				$ssh .= '-i ' . escapeshellarg($options['identity']) . ' ';
88 93
 			}
@@ -99,7 +104,9 @@  discard block
 block discarded – undo
99 104
 		);
100 105
 
101 106
 		// Alternatives
102
-		if($options['inputContent'] || $options['inputStream']) $pipeSpec[0] = array('pipe', 'r');
107
+		if($options['inputContent'] || $options['inputStream']) {
108
+			$pipeSpec[0] = array('pipe', 'r');
109
+		}
103 110
 
104 111
 		if($options['outputFile']) {
105 112
 			$pipeSpec[1] = array('file',
@@ -117,7 +124,9 @@  discard block
 block discarded – undo
117 124
 				fwrite($pipes[0], $content);
118 125
 			}
119 126
 		}
120
-		if(isset($pipes[0])) fclose($pipes[0]);
127
+		if(isset($pipes[0])) {
128
+			fclose($pipes[0]);
129
+		}
121 130
 
122 131
 		$result = array();
123 132
 
Please login to merge, or discard this patch.
src/FilesystemEntity.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,6 +23,10 @@  discard block
 block discarded – undo
23 23
 	public function isLocal() {
24 24
 		return $this->server == null;
25 25
 	}
26
+
27
+	/**
28
+	 * @return string|null
29
+	 */
26 30
 	public function getPath() {
27 31
 		return $this->path;
28 32
 	}
@@ -59,7 +63,6 @@  discard block
 block discarded – undo
59 63
 
60 64
 	/**
61 65
 	 * Upload a file to the given destination on the server
62
-	 * @param string $file The file to upload
63 66
 	 * @param string $dest The remote filename/dir to upload to
64 67
 	 */
65 68
 	public function upload($source, $dest) {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 	public function __construct($path, $executor) {
13 13
 		$this->executor = $executor;
14 14
 
15
-		if(strpos($path,':') !== false) {
16
-			list($this->server,$this->path) = explode(':', $path, 2);
15
+		if (strpos($path, ':') !== false) {
16
+			list($this->server, $this->path) = explode(':', $path, 2);
17 17
 		} else {
18 18
 			$this->server = null;
19 19
 			$this->path = $path;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @return Process
48 48
 	 */
49 49
 	public function createProcess($command, $options = array()) {
50
-		if($this->server) {
50
+		if ($this->server) {
51 51
 			if ($this->identity && !isset($options['identity'])) {
52 52
 				$options['identity'] = $this->identity;
53 53
 			}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param string $dest The remote filename/dir to upload to
64 64
 	 */
65 65
 	public function upload($source, $dest) {
66
-		if($this->server) {
66
+		if ($this->server) {
67 67
 			$this->executor->execLocal(array("scp", $source, "$this->server:$dest"));
68 68
 		} else {
69 69
 			$this->executor->execLocal(array("cp", $source, $dest));
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $dest The remote filename/dir to upload to
77 77
 	 */
78 78
 	public function uploadContent($content, $dest) {
79
-		$this->exec("echo " . escapeshellarg($content) . " > " . escapeshellarg($dest));
79
+		$this->exec("echo ".escapeshellarg($content)." > ".escapeshellarg($dest));
80 80
 	}
81 81
 
82 82
 	/**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @param string $dest The local filename/dir to download to
86 86
 	 */
87 87
 	public function download($source, $dest) {
88
-		if($this->server) {
88
+		if ($this->server) {
89 89
 			$this->executor->execLocal(array("scp", "$this->server:$source", $dest));
90 90
 		} else {
91 91
 			$this->executor->execLocal(array("cp", $file, $dest));
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 * @return boolean
99 99
 	 */
100 100
 	public function exists($file = null) {
101
-		if(!$file) $file = $this->path;
102
-		if($file == '@self') return true;
101
+		if (!$file) $file = $this->path;
102
+		if ($file == '@self') return true;
103 103
 
104
-		if($this->server) {
105
-			$result = $this->exec("if [ -e " . escapeshellarg($file) . " ]; then echo yes; fi");
104
+		if ($this->server) {
105
+			$result = $this->exec("if [ -e ".escapeshellarg($file)." ]; then echo yes; fi");
106 106
 			return (trim($result['output']) == 'yes');
107 107
 
108 108
 		} else {
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * Create the given file with the given content
115 115
 	 */
116 116
 	public function writeFile($file, $content) {
117
-		if($this->server) {
118
-			$this->exec("echo " . escapeshellarg($content) . " > " . escapeshellarg($file));
117
+		if ($this->server) {
118
+			$this->exec("echo ".escapeshellarg($content)." > ".escapeshellarg($file));
119 119
 
120 120
 		} else {
121 121
 			file_put_contents($file, $content);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $file The file to remove
129 129
 	 */
130 130
 	public function unlink($file) {
131
-		if(!$file || $file == '/' || $file == '.') throw new Exception("Can't unlink file '$file'");
131
+		if (!$file || $file == '/' || $file == '.') throw new Exception("Can't unlink file '$file'");
132 132
 		$this->exec(array('rm', '-rf', $file));
133 133
 		return true;
134 134
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -98,8 +98,12 @@  discard block
 block discarded – undo
98 98
 	 * @return boolean
99 99
 	 */
100 100
 	public function exists($file = null) {
101
-		if(!$file) $file = $this->path;
102
-		if($file == '@self') return true;
101
+		if(!$file) {
102
+			$file = $this->path;
103
+		}
104
+		if($file == '@self') {
105
+			return true;
106
+		}
103 107
 
104 108
 		if($this->server) {
105 109
 			$result = $this->exec("if [ -e " . escapeshellarg($file) . " ]; then echo yes; fi");
@@ -128,7 +132,9 @@  discard block
 block discarded – undo
128 132
 	 * @param string $file The file to remove
129 133
 	 */
130 134
 	public function unlink($file) {
131
-		if(!$file || $file == '/' || $file == '.') throw new Exception("Can't unlink file '$file'");
135
+		if(!$file || $file == '/' || $file == '.') {
136
+			throw new Exception("Can't unlink file '$file'");
137
+		}
132 138
 		$this->exec(array('rm', '-rf', $file));
133 139
 		return true;
134 140
 	}
Please login to merge, or discard this patch.
src/SSPak.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -348,6 +348,11 @@  discard block
 block discarded – undo
348 348
 		return true;
349 349
 	}
350 350
 
351
+	/**
352
+	 * @param Webroot $webroot
353
+	 * @param SSPakFile $sspak
354
+	 * @param string $filename
355
+	 */
351 356
 	public function getassets($webroot, $assetsPath, $sspak, $filename) {
352 357
 		$assetsParentArg = escapeshellarg(dirname($assetsPath));
353 358
 		$assetsBaseArg = escapeshellarg(basename($assetsPath));
@@ -356,6 +361,11 @@  discard block
 block discarded – undo
356 361
 		$sspak->writeFileFromProcess($filename, $process);
357 362
 	}
358 363
 
364
+	/**
365
+	 * @param Webroot $webroot
366
+	 * @param SSPakFile $sspak
367
+	 * @param string $gitRemoteFile
368
+	 */
359 369
 	public function getgitremote($webroot, $sspak, $gitRemoteFile) {
360 370
 		// Only do anything if we're copying from a git checkout
361 371
 		$gitRepo = $webroot->getPath() .'/.git';
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 
89 89
 	public function help($args) {
90 90
 		echo "SSPak: manage SilverStripe .sspak archives.\n\nUsage:\n";
91
-		foreach($this->getActions() as $action => $info) {
91
+		foreach ($this->getActions() as $action => $info) {
92 92
 			echo "sspak $action";
93
-			if(!empty($info['unnamedArgs'])) {
94
-				foreach($info['unnamedArgs'] as $arg) echo " ($arg)";
93
+			if (!empty($info['unnamedArgs'])) {
94
+				foreach ($info['unnamedArgs'] as $arg) echo " ($arg)";
95 95
 			}
96
-			if(!empty($info['namedFlags'])) {
97
-				foreach($info['namedFlags'] as $arg) echo " (--$arg)";
96
+			if (!empty($info['namedFlags'])) {
97
+				foreach ($info['namedFlags'] as $arg) echo " (--$arg)";
98 98
 			}
99
-			if(!empty($info['namedArgs'])) {
100
-				foreach($info['namedArgs'] as $arg) echo " --$arg=\"$arg value\"";
99
+			if (!empty($info['namedArgs'])) {
100
+				foreach ($info['namedArgs'] as $arg) echo " --$arg=\"$arg value\"";
101 101
 			}
102 102
 			echo "\n  {$info['description']}\n\n";
103 103
 		}
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 
122 122
 		$filesystem = new FilesystemEntity(null, $executor);
123 123
 
124
-		if($pakParts['db']) {
124
+		if ($pakParts['db']) {
125 125
 			$dbPath = escapeshellarg($namedArgs['db']);
126 126
 			$process = $filesystem->createProcess("cat $dbPath | gzip -c");
127 127
 			$sspak->writeFileFromProcess('database.sql.gz', $process);
128 128
 		}
129 129
 
130
-		if($pakParts['assets']) {
130
+		if ($pakParts['assets']) {
131 131
 			$assetsParentArg = escapeshellarg(dirname($namedArgs['assets']));
132 132
 			$assetsBaseArg = escapeshellarg(basename($namedArgs['assets']));
133 133
 			$process = $filesystem->createProcess("cd $assetsParentArg && tar cfh - $assetsBaseArg | gzip -c");
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		// from other formats.
156 156
 		// There is no cross-platform way of checking the assets.tar.gz size without unpacking, so we assume the size
157 157
 		// of database is negligible which lets us approximate the size of assets.
158
-		if (filesize($file) > 8*1024*1024*1024) {
158
+		if (filesize($file) > 8 * 1024 * 1024 * 1024) {
159 159
 			$msg = <<<EOM
160 160
 
161 161
 ERROR: SSPak is unable to extract archives over 8 GB.
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		$sspak = new SSPakFile($file, $executor);
177 177
 
178 178
 		// Validation
179
-		if(!$sspak->exists()) throw new Exception("File '$file' doesn't exist.");
179
+		if (!$sspak->exists()) throw new Exception("File '$file' doesn't exist.");
180 180
 
181 181
 		$phar = $sspak->getPhar();
182 182
 		$phar->extractTo($dest);
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 
208 208
 		$db = new DatabaseConnector($webroot);
209 209
 
210
-		foreach($db->getTables() as $table) {
211
-			$filename = $destPath . '/' . $table . '.csv';
212
-			echo $filename . "...\n";
210
+		foreach ($db->getTables() as $table) {
211
+			$filename = $destPath.'/'.$table.'.csv';
212
+			echo $filename."...\n";
213 213
 			touch($filename);
214 214
 			$writer = new CsvTableWriter($filename);
215 215
 			$db->saveTable($table, $writer);
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 
231 231
 		$db = new DatabaseConnector($webroot);
232 232
 
233
-		foreach($db->getTables() as $table) {
234
-			$filename = $srcPath . '/' . $table . '.csv';
235
-			if(file_exists($filename)) {
236
-				echo $filename . "...\n";
233
+		foreach ($db->getTables() as $table) {
234
+			$filename = $srcPath.'/'.$table.'.csv';
235
+			if (file_exists($filename)) {
236
+				echo $filename."...\n";
237 237
 				$reader = new CsvTableReader($filename);
238 238
 				$db->loadTable($table, $reader);
239 239
 			} else {
@@ -255,16 +255,16 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$webroot = new Webroot($unnamedArgs[0], $executor);
257 257
 		$file = $unnamedArgs[1];
258
-		if(file_exists($file)) throw new Exception( "File '$file' already exists.");
258
+		if (file_exists($file)) throw new Exception("File '$file' already exists.");
259 259
 
260 260
 		$sspak = new SSPakFile($file, $executor);
261 261
 
262
-		if(!empty($namedArgs['identity'])) {
262
+		if (!empty($namedArgs['identity'])) {
263 263
 			// SSH private key
264 264
 			$webroot->setSSHItentityFile($namedArgs['identity']);
265 265
 		}
266
-		if(!empty($namedArgs['from-sudo'])) $webroot->setSudo($namedArgs['from-sudo']);
267
-		else if(!empty($namedArgs['sudo'])) $webroot->setSudo($namedArgs['sudo']);
266
+		if (!empty($namedArgs['from-sudo'])) $webroot->setSudo($namedArgs['from-sudo']);
267
+		else if (!empty($namedArgs['sudo'])) $webroot->setSudo($namedArgs['sudo']);
268 268
 
269 269
 		// Look up which parts of the sspak are going to be saved
270 270
 		$pakParts = $args->pakParts();
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		$details = $webroot->sniff();
274 274
 
275 275
 		// Create a build folder for the sspak file
276
-		$buildFolder = "/tmp/sspak-" . rand(100000,999999);
276
+		$buildFolder = "/tmp/sspak-".rand(100000, 999999);
277 277
 		$webroot->exec(array('mkdir', $buildFolder));
278 278
 
279 279
 		$dbFile = "$buildFolder/database.sql.gz";
@@ -284,22 +284,22 @@  discard block
 block discarded – undo
284 284
 		$fileList = array();
285 285
 
286 286
 		// Save DB
287
-		if($pakParts['db']) {
287
+		if ($pakParts['db']) {
288 288
 			// Check the database type
289 289
 			$dbFunction = 'getdb_'.$details['db_type'];
290
-			if(!method_exists($this,$dbFunction)) {
291
-				throw new Exception("Can't process database type '" . $details['db_type'] . "'");
290
+			if (!method_exists($this, $dbFunction)) {
291
+				throw new Exception("Can't process database type '".$details['db_type']."'");
292 292
 			}
293 293
 			$this->$dbFunction($webroot, $details, $sspak, basename($dbFile));
294 294
 		}
295 295
 
296 296
 		// Save Assets
297
-		if($pakParts['assets']) {
297
+		if ($pakParts['assets']) {
298 298
 			$this->getassets($webroot, $details['assets_path'], $sspak, basename($assetsFile));
299 299
 		}
300 300
 
301 301
 		// Save git-remote
302
-		if($pakParts['git-remote']) {
302
+		if ($pakParts['git-remote']) {
303 303
 			$this->getgitremote($webroot, $sspak, basename($gitRemoteFile));
304 304
 		}
305 305
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		$hostArg = '';
320 320
 		$portArg = '';
321 321
 		if (!empty($conf['db_server']) && $conf['db_server'] != 'localhost') {
322
-			if (strpos($conf['db_server'], ':')!==false) {
322
+			if (strpos($conf['db_server'], ':') !== false) {
323 323
 				// Handle "server:port" format.
324 324
 				$server = explode(':', $conf['db_server'], 2);
325 325
 				$hostArg = escapeshellarg("--host=".$server[0]);
@@ -358,16 +358,16 @@  discard block
 block discarded – undo
358 358
 
359 359
 	public function getgitremote($webroot, $sspak, $gitRemoteFile) {
360 360
 		// Only do anything if we're copying from a git checkout
361
-		$gitRepo = $webroot->getPath() .'/.git';
362
-		if($webroot->exists($gitRepo)) {
361
+		$gitRepo = $webroot->getPath().'/.git';
362
+		if ($webroot->exists($gitRepo)) {
363 363
 			// Identify current branch
364 364
 			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'branch'));
365
-			if(preg_match("/\* ([^ \n]*)/", $output['output'], $matches) && strpos("(no branch)", $matches[1])===false) {
365
+			if (preg_match("/\* ([^ \n]*)/", $output['output'], $matches) && strpos("(no branch)", $matches[1]) === false) {
366 366
 				// If there is a current branch, use that branch's remove
367 367
 				$currentBranch = trim($matches[1]);
368
-				$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"branch.$currentBranch.remote"));
368
+				$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config', '--get', "branch.$currentBranch.remote"));
369 369
 				$remoteName = trim($output['output']);
370
-				if(!$remoteName) $remoteName = 'origin';
370
+				if (!$remoteName) $remoteName = 'origin';
371 371
 
372 372
 			// Default to origin
373 373
 			} else {
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
 			}
377 377
 
378 378
 			// Determine the URL of that remote
379
-			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"remote.$remoteName.url"));
379
+			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config', '--get', "remote.$remoteName.url"));
380 380
 			$remoteURL = trim($output['output']);
381 381
 
382 382
 			// Determine the current SHA
383
-			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'log','-1','--format=%H'));
383
+			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'log', '-1', '--format=%H'));
384 384
 			$sha = trim($output['output']);
385 385
 
386 386
 			$content = "remote = $remoteURL\nbranch = $currentBranch\nsha = $sha\n";
@@ -408,22 +408,22 @@  discard block
 block discarded – undo
408 408
 		$pakParts = $args->pakParts();
409 409
 
410 410
 		$namedArgs = $args->getNamedArgs();
411
-		if(!empty($namedArgs['identity'])) {
411
+		if (!empty($namedArgs['identity'])) {
412 412
 			// SSH private key
413 413
 			$webroot->setSSHItentityFile($namedArgs['identity']);
414 414
 		}
415 415
 
416 416
 		// Validation
417
-		if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist.");
417
+		if (!$sspak->exists()) throw new Exception("File '$file' doesn't exist.");
418 418
 
419 419
 		// Push database, if necessary
420 420
 		$namedArgs = $args->getNamedArgs();
421
-		if($pakParts['db'] && $sspak->contains('database.sql.gz')) {
421
+		if ($pakParts['db'] && $sspak->contains('database.sql.gz')) {
422 422
 			$webroot->putdb($sspak, isset($namedArgs['drop-db']));
423 423
 		}
424 424
 
425 425
 		// Push assets, if neccessary
426
-		if($pakParts['assets'] && $sspak->contains('assets.tar.gz')) {
426
+		if ($pakParts['assets'] && $sspak->contains('assets.tar.gz')) {
427 427
 			$webroot->putassets($sspak);
428 428
 		}
429 429
 	}
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
 		$pakParts = $args->pakParts();
446 446
 
447 447
 		// Validation
448
-		if($webroot->exists($webroot->getPath())) throw new Exception( "Webroot '$webrootDir' already exists.");
449
-		if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist.");
448
+		if ($webroot->exists($webroot->getPath())) throw new Exception("Webroot '$webrootDir' already exists.");
449
+		if (!$sspak->exists()) throw new Exception("File '$file' doesn't exist.");
450 450
 
451 451
 		// Create new dir
452 452
 		$webroot->exec(array('mkdir', $webroot->getPath()));
453 453
 
454
-		if($sspak->contains('git-remote')) {
454
+		if ($sspak->contains('git-remote')) {
455 455
 			$details = $sspak->gitRemoteDetails();
456 456
 			$webroot->putgit($details);
457 457
 		}
@@ -460,12 +460,12 @@  discard block
 block discarded – undo
460 460
 
461 461
 		// Push database, if necessary
462 462
 		$namedArgs = $args->getNamedArgs();
463
-		if($pakParts['db'] && $sspak->contains('database.sql.gz')) {
463
+		if ($pakParts['db'] && $sspak->contains('database.sql.gz')) {
464 464
 			$webroot->putdb($sspak, isset($namedArgs['drop-db']));
465 465
 		}
466 466
 
467 467
 		// Push assets, if neccessary
468
-		if($pakParts['assets'] && $sspak->contains('assets.tar.gz')) {
468
+		if ($pakParts['assets'] && $sspak->contains('assets.tar.gz')) {
469 469
 			$webroot->putassets($sspak);
470 470
 		}
471 471
 	}
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		$sspakScript = str_replace('$isSelfExtracting = false;', '$isSelfExtracting = true;', $sspakScript);
493 493
 
494 494
 		// Load the sniffer file
495
-		$snifferFile = dirname(__FILE__) . '/sspak-sniffer.php';
495
+		$snifferFile = dirname(__FILE__).'/sspak-sniffer.php';
496 496
 		$sspakScript = str_replace("\$snifferFileContent = '';\n",
497 497
 			"\$snifferFileContent = '"
498
-			. str_replace(array("\\","'"),array("\\\\", "\\'"), file_get_contents($snifferFile)) . "';\n", $sspakScript);
498
+			. str_replace(array("\\", "'"), array("\\\\", "\\'"), file_get_contents($snifferFile))."';\n", $sspakScript);
499 499
 
500 500
 		file_put_contents($destFile, $sspakScript);
501 501
 		chmod($destFile, 0775);
Please login to merge, or discard this patch.
Braces   +32 added lines, -11 removed lines patch added patch discarded remove patch
@@ -91,13 +91,19 @@  discard block
 block discarded – undo
91 91
 		foreach($this->getActions() as $action => $info) {
92 92
 			echo "sspak $action";
93 93
 			if(!empty($info['unnamedArgs'])) {
94
-				foreach($info['unnamedArgs'] as $arg) echo " ($arg)";
94
+				foreach($info['unnamedArgs'] as $arg) {
95
+					echo " ($arg)";
96
+				}
95 97
 			}
96 98
 			if(!empty($info['namedFlags'])) {
97
-				foreach($info['namedFlags'] as $arg) echo " (--$arg)";
99
+				foreach($info['namedFlags'] as $arg) {
100
+					echo " (--$arg)";
101
+				}
98 102
 			}
99 103
 			if(!empty($info['namedArgs'])) {
100
-				foreach($info['namedArgs'] as $arg) echo " --$arg=\"$arg value\"";
104
+				foreach($info['namedArgs'] as $arg) {
105
+					echo " --$arg=\"$arg value\"";
106
+				}
101 107
 			}
102 108
 			echo "\n  {$info['description']}\n\n";
103 109
 		}
@@ -176,7 +182,9 @@  discard block
 block discarded – undo
176 182
 		$sspak = new SSPakFile($file, $executor);
177 183
 
178 184
 		// Validation
179
-		if(!$sspak->exists()) throw new Exception("File '$file' doesn't exist.");
185
+		if(!$sspak->exists()) {
186
+			throw new Exception("File '$file' doesn't exist.");
187
+		}
180 188
 
181 189
 		$phar = $sspak->getPhar();
182 190
 		$phar->extractTo($dest);
@@ -255,7 +263,9 @@  discard block
 block discarded – undo
255 263
 
256 264
 		$webroot = new Webroot($unnamedArgs[0], $executor);
257 265
 		$file = $unnamedArgs[1];
258
-		if(file_exists($file)) throw new Exception( "File '$file' already exists.");
266
+		if(file_exists($file)) {
267
+			throw new Exception( "File '$file' already exists.");
268
+		}
259 269
 
260 270
 		$sspak = new SSPakFile($file, $executor);
261 271
 
@@ -263,8 +273,11 @@  discard block
 block discarded – undo
263 273
 			// SSH private key
264 274
 			$webroot->setSSHItentityFile($namedArgs['identity']);
265 275
 		}
266
-		if(!empty($namedArgs['from-sudo'])) $webroot->setSudo($namedArgs['from-sudo']);
267
-		else if(!empty($namedArgs['sudo'])) $webroot->setSudo($namedArgs['sudo']);
276
+		if(!empty($namedArgs['from-sudo'])) {
277
+			$webroot->setSudo($namedArgs['from-sudo']);
278
+		} else if(!empty($namedArgs['sudo'])) {
279
+			$webroot->setSudo($namedArgs['sudo']);
280
+		}
268 281
 
269 282
 		// Look up which parts of the sspak are going to be saved
270 283
 		$pakParts = $args->pakParts();
@@ -367,7 +380,9 @@  discard block
 block discarded – undo
367 380
 				$currentBranch = trim($matches[1]);
368 381
 				$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"branch.$currentBranch.remote"));
369 382
 				$remoteName = trim($output['output']);
370
-				if(!$remoteName) $remoteName = 'origin';
383
+				if(!$remoteName) {
384
+					$remoteName = 'origin';
385
+				}
371 386
 
372 387
 			// Default to origin
373 388
 			} else {
@@ -414,7 +429,9 @@  discard block
 block discarded – undo
414 429
 		}
415 430
 
416 431
 		// Validation
417
-		if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist.");
432
+		if(!$sspak->exists()) {
433
+			throw new Exception( "File '$file' doesn't exist.");
434
+		}
418 435
 
419 436
 		// Push database, if necessary
420 437
 		$namedArgs = $args->getNamedArgs();
@@ -445,8 +462,12 @@  discard block
 block discarded – undo
445 462
 		$pakParts = $args->pakParts();
446 463
 
447 464
 		// Validation
448
-		if($webroot->exists($webroot->getPath())) throw new Exception( "Webroot '$webrootDir' already exists.");
449
-		if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist.");
465
+		if($webroot->exists($webroot->getPath())) {
466
+			throw new Exception( "Webroot '$webrootDir' already exists.");
467
+		}
468
+		if(!$sspak->exists()) {
469
+			throw new Exception( "File '$file' doesn't exist.");
470
+		}
450 471
 
451 472
 		// Create new dir
452 473
 		$webroot->exec(array('mkdir', $webroot->getPath()));
Please login to merge, or discard this patch.
src/Webroot.php 3 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,9 +66,8 @@  discard block
 block discarded – undo
66 66
 
67 67
 	/**
68 68
 	 * Put the database from the given sspak file into this webroot.
69
-	 * @param array $details The previously sniffed details of this webroot
70 69
 	 * @param bool $dropdb Drop the DB prior to install
71
-	 * @param string $sspakFile Filename
70
+	 * @param SSPakFile $sspak Filename
72 71
 	 */
73 72
 	public function putdb($sspak, $dropdb) {
74 73
 		$details = $this->details();
@@ -135,6 +134,9 @@  discard block
 block discarded – undo
135 134
 		fclose($stream);
136 135
 	}
137 136
 
137
+	/**
138
+	 * @param SSPakFile $sspak
139
+	 */
138 140
 	public function putassets($sspak) {
139 141
 		$details = $this->details();
140 142
 		$assetsPath = $details['assets_path'];
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	 * Calls sniff once and then caches
17 17
 	 */
18 18
 	public function details() {
19
-		if(!$this->details) $this->details = $this->sniff();
19
+		if(!$this->details) {
20
+			$this->details = $this->sniff();
21
+		}
20 22
 		return $this->details;
21 23
 	}
22 24
 
@@ -26,7 +28,9 @@  discard block
 block discarded – undo
26 28
 	public function sniff() {
27 29
 		global $snifferFileContent;
28 30
 
29
-		if(!$snifferFileContent) $snifferFileContent = file_get_contents(PACKAGE_ROOT . 'src/sspak-sniffer.php');
31
+		if(!$snifferFileContent) {
32
+			$snifferFileContent = file_get_contents(PACKAGE_ROOT . 'src/sspak-sniffer.php');
33
+		}
30 34
 
31 35
 		$remoteSniffer = '/tmp/sspak-sniffer-' . rand(100000,999999) . '.php';
32 36
 		$this->uploadContent($snifferFileContent, $remoteSniffer);
@@ -35,7 +39,9 @@  discard block
 block discarded – undo
35 39
 		$this->unlink($remoteSniffer);
36 40
 
37 41
 		$parsed = @unserialize($result['output']);
38
-		if(!$parsed) throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n");
42
+		if(!$parsed) {
43
+			throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n");
44
+		}
39 45
 		return $parsed;
40 46
 	}
41 47
 
@@ -45,7 +51,9 @@  discard block
 block discarded – undo
45 51
 	 */
46 52
 	public function execSudo($command) {
47 53
 		if($this->sudo) {
48
-			if(is_array($command)) $command = $this->executor->commandArrayToString($command);
54
+			if(is_array($command)) {
55
+				$command = $this->executor->commandArrayToString($command);
56
+			}
49 57
 			// Try running sudo without asking for a password
50 58
 			try {
51 59
 				return $this->exec("sudo -n -u " . escapeshellarg($this->sudo) . " " . $command);
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 * Calls sniff once and then caches
17 17
 	 */
18 18
 	public function details() {
19
-		if(!$this->details) $this->details = $this->sniff();
19
+		if (!$this->details) $this->details = $this->sniff();
20 20
 		return $this->details;
21 21
 	}
22 22
 
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
 	public function sniff() {
27 27
 		global $snifferFileContent;
28 28
 
29
-		if(!$snifferFileContent) $snifferFileContent = file_get_contents(PACKAGE_ROOT . 'src/sspak-sniffer.php');
29
+		if (!$snifferFileContent) $snifferFileContent = file_get_contents(PACKAGE_ROOT.'src/sspak-sniffer.php');
30 30
 
31
-		$remoteSniffer = '/tmp/sspak-sniffer-' . rand(100000,999999) . '.php';
31
+		$remoteSniffer = '/tmp/sspak-sniffer-'.rand(100000, 999999).'.php';
32 32
 		$this->uploadContent($snifferFileContent, $remoteSniffer);
33 33
 
34 34
 		$result = $this->execSudo(array('/usr/bin/env', 'php', $remoteSniffer, $this->path));
35 35
 		$this->unlink($remoteSniffer);
36 36
 
37 37
 		$parsed = @unserialize($result['output']);
38
-		if(!$parsed) throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n");
38
+		if (!$parsed) throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n");
39 39
 		return $parsed;
40 40
 	}
41 41
 
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
 	 * @param  string $command Shell command, either a fully escaped string or an array
45 45
 	 */
46 46
 	public function execSudo($command) {
47
-		if($this->sudo) {
48
-			if(is_array($command)) $command = $this->executor->commandArrayToString($command);
47
+		if ($this->sudo) {
48
+			if (is_array($command)) $command = $this->executor->commandArrayToString($command);
49 49
 			// Try running sudo without asking for a password
50 50
 			try {
51
-				return $this->exec("sudo -n -u " . escapeshellarg($this->sudo) . " " . $command);
51
+				return $this->exec("sudo -n -u ".escapeshellarg($this->sudo)." ".$command);
52 52
 
53 53
 			// Otherwise capture SUDO password ourselves and pass it in through STDIN
54
-			} catch(Exception $e) {
54
+			} catch (Exception $e) {
55 55
 				echo "[sspak sudo] Enter your password: ";
56
-				$stdin = fopen( 'php://stdin', 'r');
56
+				$stdin = fopen('php://stdin', 'r');
57 57
 				$password = fgets($stdin);
58 58
 
59
-				return $this->exec("sudo -S -p '' -u " . escapeshellarg($this->sudo) . " " . $command, array('inputContent' => $password));
59
+				return $this->exec("sudo -S -p '' -u ".escapeshellarg($this->sudo)." ".$command, array('inputContent' => $password));
60 60
 			}
61 61
 
62 62
 		} else {
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 
76 76
 		// Check the database type
77 77
 		$dbFunction = 'putdb_'.$details['db_type'];
78
-		if(!method_exists($this,$dbFunction)) {
79
-			throw new Exception("Can't process database type '" . $details['db_type'] . "'");
78
+		if (!method_exists($this, $dbFunction)) {
79
+			throw new Exception("Can't process database type '".$details['db_type']."'");
80 80
 		}
81 81
 
82 82
 		// Extract DB direct from sspak file
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		$hostArg = '';
96 96
 		$portArg = '';
97 97
 		if (!empty($conf['db_server']) && $conf['db_server'] != 'localhost') {
98
-			if (strpos($conf['db_server'], ':')!==false) {
98
+			if (strpos($conf['db_server'], ':') !== false) {
99 99
 				// Handle "server:port" format.
100 100
 				$server = explode(':', $conf['db_server'], 2);
101 101
 				$hostArg = escapeshellarg("--host=".$server[0]);
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 				$hostArg = escapeshellarg("--host=".$conf['db_server']);
105 105
 			}
106 106
 		}
107
-		$dbCommand = "create database if not exists `" . addslashes($conf['db_database']) . "`";
108
-		if($dropdb) {
109
-			$dbCommand = "drop database if exists `" . addslashes($conf['db_database']) . "`; " . $dbCommand;
107
+		$dbCommand = "create database if not exists `".addslashes($conf['db_database'])."`";
108
+		if ($dropdb) {
109
+			$dbCommand = "drop database if exists `".addslashes($conf['db_database'])."`; ".$dbCommand;
110 110
 		}
111 111
 
112 112
 		$this->exec("echo '$dbCommand' | mysql $usernameArg $passwordArg $hostArg $portArg");
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 		// Create database if needed
128 128
 		$result = $this->exec("echo \"select count(*) from pg_catalog.pg_database where datname = $databaseArg\" | $passwordArg psql $usernameArg $hostArg $databaseArg -qt");
129
-		if(trim($result['output']) == '0') {
129
+		if (trim($result['output']) == '0') {
130 130
 			$this->exec("$passwordArg createdb $usernameArg $hostArg $databaseArg");
131 131
 		}
132 132
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		$assetsPathExec = $this->exec("if [ -L {$assetsPath} ]; then readlink -f {$assetsPath}; else echo {$assetsPath}; fi");
145 145
 		$assetsPath = trim($assetsPathExec["output"]);
146 146
 
147
-		$assetsOldPath = $assetsPath . '.old';
147
+		$assetsOldPath = $assetsPath.'.old';
148 148
 		$assetsParentArg = escapeshellarg(dirname($assetsPath));
149 149
 
150 150
 		// Move existing assets to assets.old
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function putgit($details) {
169 169
 		$this->exec(array('git', 'clone', $details['remote'], $this->path));
170
-		$this->exec("cd $this->path && git checkout " . escapeshellarg($details['branch']));
170
+		$this->exec("cd $this->path && git checkout ".escapeshellarg($details['branch']));
171 171
 		return true;
172 172
 	}
173 173
 }
Please login to merge, or discard this patch.