Completed
Push — master ( 382c63...5355c1 )
by rugk
02:29
created
source/Threema/Console/Command/LookupPublicKeyById.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 		$connector = new Connection($settings, $this->publicKeyStore);
43 43
 
44 44
 		$result = $connector->fetchPublicKey($id);
45
-		if($result->isSuccess()) {
45
+		if ($result->isSuccess()) {
46 46
 			Common::l(Common::convertPublicKey($result->getPublicKey()));
47 47
 		}
48 48
 		else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@
 block discarded – undo
44 44
 		$result = $connector->fetchPublicKey($id);
45 45
 		if($result->isSuccess()) {
46 46
 			Common::l(Common::convertPublicKey($result->getPublicKey()));
47
-		}
48
-		else {
47
+		} else {
49 48
 			Common::e($result->getErrorMessage());
50 49
 		}
51 50
 	}
Please login to merge, or discard this patch.
source/Threema/Console/Command/ReceiveMessage.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,14 +61,14 @@
 block discarded – undo
61 61
 			$outputFolder
62 62
 		);
63 63
 
64
-		if(null === $message) {
64
+		if (null === $message) {
65 65
 			Common::e('invalid message');
66 66
 			return;
67 67
 		}
68 68
 
69
-		if($message->isSuccess()) {
69
+		if ($message->isSuccess()) {
70 70
 			Common::l($message->getMessageId().' - '.$message->getThreemaMessage());
71
-			foreach($message->getFiles() as $fileName => $filePath) {
71
+			foreach ($message->getFiles() as $fileName => $filePath) {
72 72
 				Common::l('   received file '.$fileName.' in '.$filePath);
73 73
 			}
74 74
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,8 +71,7 @@
 block discarded – undo
71 71
 			foreach($message->getFiles() as $fileName => $filePath) {
72 72
 				Common::l('   received file '.$fileName.' in '.$filePath);
73 73
 			}
74
-		}
75
-		else {
74
+		} else {
76 75
 			Common::e('Error: '.implode("\n", $message->getErrors()));
77 76
 		}
78 77
 	}
Please login to merge, or discard this patch.
source/Threema/Console/Command/SendE2EFile.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 		$helper = new E2EHelper($privateKey, $connector);
54 54
 		$result = $helper->sendFileMessage($threemaId, $path, $thumbnailPath);
55 55
 
56
-		if($result->isSuccess()) {
56
+		if ($result->isSuccess()) {
57 57
 			Common::l('Message ID: '.$result->getMessageId());
58 58
 		}
59 59
 		else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@
 block discarded – undo
55 55
 
56 56
 		if($result->isSuccess()) {
57 57
 			Common::l('Message ID: '.$result->getMessageId());
58
-		}
59
-		else {
58
+		} else {
60 59
 			Common::e('Error: '.$result->getErrorMessage());
61 60
 		}
62 61
 	}
Please login to merge, or discard this patch.
source/Threema/Console/Command/SendE2EImage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 		$helper = new E2EHelper($privateKey, $connector);
52 52
 		$result = $helper->sendImageMessage($threemaId, $path);
53 53
 
54
-		if($result->isSuccess()) {
54
+		if ($result->isSuccess()) {
55 55
 			Common::l('Message ID: '.$result->getMessageId());
56 56
 		}
57 57
 		else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@
 block discarded – undo
55 55
 
56 56
 		if($result->isSuccess()) {
57 57
 			Common::l('Message ID: '.$result->getMessageId());
58
-		}
59
-		else {
58
+		} else {
60 59
 			Common::e('Error: '.$result->getErrorMessage());
61 60
 		}
62 61
 	}
Please login to merge, or discard this patch.
source/Threema/Console/Command/SendE2EText.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		Common::required($threemaId, $from, $secret, $privateKey);
39 39
 
40 40
 		$message = $this->readStdIn();
41
-		if(strlen($message) === 0) {
41
+		if (strlen($message) === 0) {
42 42
 			throw new \InvalidArgumentException('please define a message');
43 43
 		}
44 44
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		$helper = new E2EHelper($privateKey, $connector);
53 53
 		$result = $helper->sendTextMessage($threemaId, $message);
54 54
 
55
-		if($result->isSuccess()) {
55
+		if ($result->isSuccess()) {
56 56
 			Common::l('Message ID: '.$result->getMessageId());
57 57
 		}
58 58
 		else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@
 block discarded – undo
55 55
 
56 56
 		if($result->isSuccess()) {
57 57
 			Common::l('Message ID: '.$result->getMessageId());
58
-		}
59
-		else {
58
+		} else {
60 59
 			Common::e('Error: '.$result->getErrorMessage());
61 60
 		}
62 61
 	}
Please login to merge, or discard this patch.
source/Threema/Console/Command/SendSimple.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		Common::required($to, $from, $secret);
37 37
 
38 38
 		$message = $this->readStdIn();
39
-		if(strlen($message) === 0) {
39
+		if (strlen($message) === 0) {
40 40
 			throw new \InvalidArgumentException('please define a message');
41 41
 		}
42 42
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		$receiver = new Receiver($to, Receiver::TYPE_ID);
50 50
 
51 51
 		$result = $connector->sendSimple($receiver, $message);
52
-		if($result->isSuccess()) {
52
+		if ($result->isSuccess()) {
53 53
 			Common::l('Message ID: '.$result->getMessageId());
54 54
 		}
55 55
 		else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@
 block discarded – undo
51 51
 		$result = $connector->sendSimple($receiver, $message);
52 52
 		if($result->isSuccess()) {
53 53
 			Common::l('Message ID: '.$result->getMessageId());
54
-		}
55
-		else {
54
+		} else {
56 55
 			Common::l('Error: '.$result->getErrorMessage());
57 56
 		}
58 57
 	}
Please login to merge, or discard this patch.
source/Threema/Console/Common.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	public static function l($string = '', $indent = 0) {
21 21
 		$pad = str_repeat('  ', $indent);
22
-		echo $pad . wordwrap($string, 100, "\n" . $pad) . "\n";
22
+		echo $pad.wordwrap($string, 100, "\n".$pad)."\n";
23 23
 	}
24 24
 
25 25
 	/**
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param string $string string to output
29 29
 	 */
30 30
 	public static function ln($string = '') {
31
-		echo $string . "\n";
31
+		echo $string."\n";
32 32
 	}
33 33
 
34 34
 	/**
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public static function required() {
52 52
 		$argCount = func_num_args();
53
-		for($n = 0; $n < $argCount; $n++) {
53
+		for ($n = 0; $n < $argCount; $n++) {
54 54
 			$o = func_get_arg($n);
55
-			if(null === $o || (is_scalar($o) && strlen($o) == 0)) {
55
+			if (null === $o || (is_scalar($o) && strlen($o) == 0)) {
56 56
 				throw new Exception('invalid data');
57 57
 			}
58 58
 		}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @return null|string
66 66
 	 */
67 67
 	public static function convertPublicKey($key) {
68
-		if(null !== $key) {
68
+		if (null !== $key) {
69 69
 			return Constants::PUBLIC_KEY_PREFIX.$key;
70 70
 		}
71 71
 		return null;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return null|string
79 79
 	 */
80 80
 	public static function getPublicKey($stringWithPrefix = null) {
81
-		if(null !== $stringWithPrefix && substr($stringWithPrefix, 0, strlen(Constants::PUBLIC_KEY_PREFIX)) == Constants::PUBLIC_KEY_PREFIX) {
81
+		if (null !== $stringWithPrefix && substr($stringWithPrefix, 0, strlen(Constants::PUBLIC_KEY_PREFIX)) == Constants::PUBLIC_KEY_PREFIX) {
82 82
 			return substr($stringWithPrefix, strlen(Constants::PUBLIC_KEY_PREFIX));
83 83
 		}
84 84
 		return null;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return null|string
92 92
 	 */
93 93
 	public static function convertPrivateKey($key) {
94
-		if(null !== $key) {
94
+		if (null !== $key) {
95 95
 			return Constants::PRIVATE_KEY_PREFIX.$key;
96 96
 		}
97 97
 		return null;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return null|string
105 105
 	 */
106 106
 	public static function getPrivateKey($stringWithPrefix = null) {
107
-		if(null !== $stringWithPrefix && substr($stringWithPrefix, 0, strlen(Constants::PRIVATE_KEY_PREFIX)) == Constants::PRIVATE_KEY_PREFIX) {
107
+		if (null !== $stringWithPrefix && substr($stringWithPrefix, 0, strlen(Constants::PRIVATE_KEY_PREFIX)) == Constants::PRIVATE_KEY_PREFIX) {
108 108
 			return substr($stringWithPrefix, strlen(Constants::PRIVATE_KEY_PREFIX));
109 109
 		}
110 110
 		return null;
Please login to merge, or discard this patch.
source/Threema/Console/Run.php 2 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -138,14 +138,12 @@  discard block
 block discarded – undo
138 138
 
139 139
 		if(null === $found) {
140 140
 			$this->help();
141
-		}
142
-		else {
141
+		} else {
143 142
 
144 143
 
145 144
 			try {
146 145
 				$found->run($this->arguments);
147
-			}
148
-			catch(Exception $x) {
146
+			} catch(Exception $x) {
149 147
 				Common::l();
150 148
 				Common::e('ERROR: '.$x->getMessage());
151 149
 				Common::e(get_class($x));
@@ -168,8 +166,7 @@  discard block
 block discarded – undo
168 166
 				Common::l($data);
169 167
 				Common::l(str_repeat('-', strlen($data)));
170 168
 				Common::l();
171
-			}
172
-			else {
169
+			} else {
173 170
 				list($key, $command) = $data;
174 171
 				Common::ln($this->scriptName.' '."\033[1;33m".implode(' ', $key)."\033[0m".' '.$command->help());
175 172
 				Common::l();
@@ -186,8 +183,7 @@  discard block
 block discarded – undo
186 183
 			foreach($this->commands as $data) {
187 184
 				if(is_scalar($data)) {
188 185
 					$writer->__invoke($data, null, null, false);
189
-				}
190
-				else {
186
+				} else {
191 187
 					list($key, $command) = $data;
192 188
 					$writer->__invoke($command->subject(false), $this->scriptName.' '.implode(' ', $key).' '.$command->help(false), $command->description(), true);
193 189
 				}
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	private function register($argumentKey, Base $command) {
91
-		if(is_scalar($argumentKey)) {
91
+		if (is_scalar($argumentKey)) {
92 92
 			$argumentKey = array($argumentKey);
93 93
 		}
94 94
 
95 95
 		//check for existing commands with the same arguments
96
-		foreach($this->commands as $commandValues) {
96
+		foreach ($this->commands as $commandValues) {
97 97
 			$ex = $commandValues[0];
98
-			if(null !== $ex && is_array($ex)) {
99
-				if(count($ex) == count($argumentKey)
98
+			if (null !== $ex && is_array($ex)) {
99
+				if (count($ex) == count($argumentKey)
100 100
 					&& count(array_diff($ex, $argumentKey)) == 0) {
101 101
 					throw new Exception('arguments '.implode($argumentKey).' already used');
102 102
 				}
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
 		$argumentLength = 0;
116 116
 
117 117
 		//find the correct command by arguments and arguments count
118
-		foreach($this->commands as $data) {
119
-			if(is_scalar($data)) {
118
+		foreach ($this->commands as $data) {
119
+			if (is_scalar($data)) {
120 120
 				continue;
121 121
 			}
122 122
 
123 123
 			list($keys, $command) = $data;
124
-			if(array_slice($this->arguments, 0, count($keys)) == $keys) {
124
+			if (array_slice($this->arguments, 0, count($keys)) == $keys) {
125 125
 				$argCount = count($this->arguments)-count($keys);
126 126
 
127 127
 				/** @noinspection PhpUndefinedMethodInspection */
128
-				if($argCount >= $command->getRequiredArgumentCount()
128
+				if ($argCount >= $command->getRequiredArgumentCount()
129 129
 					&& $argCount <= $command->getAllArgumentsCount()) {
130 130
 					$found = $command;
131 131
 					$argumentLength = count($keys);
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 			}
135 135
 		}
136 136
 
137
-		if($argumentLength > 0) {
137
+		if ($argumentLength > 0) {
138 138
 			array_splice($this->arguments, 0, $argumentLength);
139 139
 		}
140 140
 
141
-		if(null === $found) {
141
+		if (null === $found) {
142 142
 			$this->help();
143 143
 		}
144 144
 		else {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			try {
148 148
 				$found->run($this->arguments);
149 149
 			}
150
-			catch(Exception $x) {
150
+			catch (Exception $x) {
151 151
 				Common::l();
152 152
 				Common::e('ERROR: '.$x->getMessage());
153 153
 				Common::e(get_class($x));
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 		Common::l('CryptTool: '.$defaultCryptTool->getName().' ('.$defaultCryptTool->getDescription().')');
167 167
 		Common::l(str_repeat('.', 40));
168 168
 		Common::l();
169
-		foreach($this->commands as $data) {
170
-			if(is_scalar($data)) {
169
+		foreach ($this->commands as $data) {
170
+			if (is_scalar($data)) {
171 171
 				Common::l($data);
172 172
 				Common::l(str_repeat('-', strlen($data)));
173 173
 				Common::l();
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 	}
185 185
 
186 186
 	public function writeHelp(\Closure $writer) {
187
-		if(null !== $writer) {
187
+		if (null !== $writer) {
188 188
 
189
-			foreach($this->commands as $data) {
190
-				if(is_scalar($data)) {
189
+			foreach ($this->commands as $data) {
190
+				if (is_scalar($data)) {
191 191
 					$writer->__invoke($data, null, null, false);
192 192
 				}
193 193
 				else {
Please login to merge, or discard this patch.
source/Threema/Core/AssocArray.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return mixed|null return the key value or the default value
29 29
 	 */
30 30
 	public function getValue($key, $defaultValue = null) {
31
-		if(false === array_key_exists($key, $this->data)) {
31
+		if (false === array_key_exists($key, $this->data)) {
32 32
 			return $defaultValue;
33 33
 		}
34 34
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static final function byJsonString($string, array $requiredKeys = null) {
45 45
 		$v = json_decode($string, true);
46
-		if(null === $v || false === $v) {
46
+		if (null === $v || false === $v) {
47 47
 			throw new Exception('invalid json string');
48 48
 		}
49 49
 
50 50
 		//validate first
51
-		if(null !== $requiredKeys) {
51
+		if (null !== $requiredKeys) {
52 52
 			//validate array first
53
-			foreach($requiredKeys as $requiredKey) {
54
-				if(false === array($v)) {
53
+			foreach ($requiredKeys as $requiredKey) {
54
+				if (false === array($v)) {
55 55
 					throw new Exception('required key '.$requiredKey.' failed');
56 56
 				}
57 57
 			}
Please login to merge, or discard this patch.