Completed
Push — master ( 2a7bb1...68cb6f )
by rugk
02:50
created
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
@@ -41,8 +41,7 @@
 block discarded – undo
41 41
 		$storeHandle = fopen($this->file, 'r');
42 42
 		if(false === $storeHandle) {
43 43
 			throw new Exception('could not open file '.$this->file);
44
-		}
45
-		else {
44
+		} else {
46 45
 			$threemaId = strtoupper($threemaId);
47 46
 			$publicKey = null;
48 47
 			while (!feof($storeHandle)) {
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
@@ -41,8 +41,7 @@
 block discarded – undo
41 41
 		$storeHandle = fopen($this->file, 'r');
42 42
 		if(false === $storeHandle) {
43 43
 			throw new Exception('could not open file '.$this->file);
44
-		}
45
-		else {
44
+		} else {
46 45
 			$threemaId = strtoupper($threemaId);
47 46
 			$publicKey = null;
48 47
 			while (!feof($storeHandle)) {
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
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	private function register($argumentKey, Base $command) {
89
-		if(is_scalar($argumentKey)) {
89
+		if (is_scalar($argumentKey)) {
90 90
 			$argumentKey = array($argumentKey);
91 91
 		}
92 92
 
93 93
 		//check for existing commands with the same arguments
94
-		foreach($this->commands as $commandValues) {
94
+		foreach ($this->commands as $commandValues) {
95 95
 			$ex = $commandValues[0];
96
-			if(null !== $ex && is_array($ex)) {
97
-				if(count($ex) == count($argumentKey)
96
+			if (null !== $ex && is_array($ex)) {
97
+				if (count($ex) == count($argumentKey)
98 98
 					&& count(array_diff($ex, $argumentKey)) == 0) {
99 99
 					throw new Exception('arguments '.implode($argumentKey).' already used');
100 100
 				}
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 		$argumentLength = 0;
114 114
 
115 115
 		//find the correct command by arguments and arguments count
116
-		foreach($this->commands as $data) {
117
-			if(is_scalar($data)) {
116
+		foreach ($this->commands as $data) {
117
+			if (is_scalar($data)) {
118 118
 				continue;
119 119
 			}
120 120
 
121 121
 			list($keys, $command) = $data;
122
-			if(array_slice($this->arguments, 0, count($keys)) == $keys) {
122
+			if (array_slice($this->arguments, 0, count($keys)) == $keys) {
123 123
 				$argCount = count($this->arguments)-count($keys);
124 124
 
125 125
 				/** @noinspection PhpUndefinedMethodInspection */
126
-				if($argCount >= $command->getRequiredArgumentCount()
126
+				if ($argCount >= $command->getRequiredArgumentCount()
127 127
 					&& $argCount <= $command->getAllArgumentsCount()) {
128 128
 					$found = $command;
129 129
 					$argumentLength = count($keys);
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 			}
133 133
 		}
134 134
 
135
-		if($argumentLength > 0) {
135
+		if ($argumentLength > 0) {
136 136
 			array_splice($this->arguments, 0, $argumentLength);
137 137
 		}
138 138
 
139
-		if(null === $found) {
139
+		if (null === $found) {
140 140
 			$this->help();
141 141
 		}
142 142
 		else {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			try {
146 146
 				$found->run($this->arguments);
147 147
 			}
148
-			catch(Exception $x) {
148
+			catch (Exception $x) {
149 149
 				Common::l();
150 150
 				Common::e('ERROR: '.$x->getMessage());
151 151
 				Common::e(get_class($x));
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 		Common::l('CryptTool: '.$defaultCryptTool->getName().' '.$defaultCryptTool->getDescription());
164 164
 		Common::l(str_repeat('.', 40));
165 165
 		Common::l();
166
-		foreach($this->commands as $data) {
167
-			if(is_scalar($data)) {
166
+		foreach ($this->commands as $data) {
167
+			if (is_scalar($data)) {
168 168
 				Common::l($data);
169 169
 				Common::l(str_repeat('-', strlen($data)));
170 170
 				Common::l();
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	}
182 182
 
183 183
 	public function writeHelp(\Closure $writer) {
184
-		if(null !== $writer) {
184
+		if (null !== $writer) {
185 185
 
186
-			foreach($this->commands as $data) {
187
-				if(is_scalar($data)) {
186
+			foreach ($this->commands as $data) {
187
+				if (is_scalar($data)) {
188 188
 					$writer->__invoke($data, null, null, false);
189 189
 				}
190 190
 				else {
Please login to merge, or discard this patch.
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.
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.
source/Threema/Core/Url.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param string $value
39 39
 	 * @return $this
40 40
 	 */
41
-	public function setValue($key, $value){
41
+	public function setValue($key, $value) {
42 42
 		$this->values[$key] = $value;
43 43
 		return $this;
44 44
 	}
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 	 * @return $this
51 51
 	 */
52 52
 	public function addPath($path) {
53
-		while(substr($this->path, strlen($this->path)-1) == '/') {
53
+		while (substr($this->path, strlen($this->path)-1) == '/') {
54 54
 			$this->path = substr($this->path, 0, strlen($this->path)-1);
55 55
 		}
56 56
 
57 57
 		$realPath = '';
58
-		foreach(explode('/', $path) as $c => $pathPiece) {
59
-			if($c > 0) {
58
+		foreach (explode('/', $path) as $c => $pathPiece) {
59
+			if ($c > 0) {
60 60
 				$realPath .= '/';
61 61
 			}
62 62
 			$realPath .= urlencode($pathPiece);
63 63
 		}
64
-		while(substr($path, 0, 1) == '/') {
64
+		while (substr($path, 0, 1) == '/') {
65 65
 			$path = substr($path, 1);
66 66
 		}
67 67
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function getPath() {
76 76
 		$p = $this->path;
77
-		if(count($this->values) > 0) {
77
+		if (count($this->values) > 0) {
78 78
 			$s = http_build_query($this->values);
79
-			if(strlen($s) > 0) {
79
+			if (strlen($s) > 0) {
80 80
 				$p .= '?'.$s;
81 81
 			}
82 82
 		}
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 	{
101 101
 		$result = array();
102 102
 
103
-		while(strlen($urlParameter) > 0) {
103
+		while (strlen($urlParameter) > 0) {
104 104
 			// name
105
-			$keyPosition= strpos($urlParameter,'=');
106
-			$keyValue = substr($urlParameter,0,$keyPosition);
105
+			$keyPosition = strpos($urlParameter, '=');
106
+			$keyValue = substr($urlParameter, 0, $keyPosition);
107 107
 			// value
108
-			$valuePosition = strpos($urlParameter,'&') ? strpos($urlParameter,'&'): strlen($urlParameter);
109
-			$valueValue = substr($urlParameter,$keyPosition+1,$valuePosition-$keyPosition-1);
108
+			$valuePosition = strpos($urlParameter, '&') ? strpos($urlParameter, '&') : strlen($urlParameter);
109
+			$valueValue = substr($urlParameter, $keyPosition+1, $valuePosition-$keyPosition-1);
110 110
 
111 111
 			// decoding the response
112 112
 			$result[$keyValue] = urldecode($valueValue);
113
-			$urlParameter = substr($urlParameter,$valuePosition+1,strlen($urlParameter));
113
+			$urlParameter = substr($urlParameter, $valuePosition+1, strlen($urlParameter));
114 114
 		}
115 115
 
116 116
 		return $result;
Please login to merge, or discard this patch.
source/Threema/MsgApi/Commands/Results/Result.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 	 * @return null|int
37 37
 	 */
38 38
 	final public function getErrorCode() {
39
-		if(false === $this->isSuccess()) {
39
+		if (false === $this->isSuccess()) {
40 40
 			return $this->httpCode;
41 41
 		}
42 42
 		return null;
Please login to merge, or discard this patch.
source/Threema/MsgApi/Commands/Results/UploadFileResult.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 	 * @return string
35 35
 	 */
36 36
 	protected function getErrorMessageByErrorCode($httpCode) {
37
-		switch($httpCode) {
37
+		switch ($httpCode) {
38 38
 			case 401:
39 39
 				return 'API identity or secret incorrect or file is empty';
40 40
 			case 402:
Please login to merge, or discard this patch.
source/Threema/MsgApi/Helpers/E2EHelper.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -247,8 +247,7 @@
 block discarded – undo
247 247
 
248 248
 				$receiveResult->addFile('image', $filePath);
249 249
 			}
250
-		}
251
-		else if($message instanceof FileMessage) {
250
+		} else if($message instanceof FileMessage) {
252 251
 			$result = $this->downloadFile($message, $message->getBlobId(), $downloadMessage);
253 252
 
254 253
 			if(null !== $result && true === $result->isSuccess()) {
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$this->cryptTool = $cryptTool;
43 43
 		$this->privateKey = $privateKey;
44 44
 
45
-		if(null === $this->cryptTool) {
45
+		if (null === $this->cryptTool) {
46 46
 			$this->cryptTool = CryptTool::getInstance();
47 47
 		}
48 48
 	}
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 		//analyse the file
85 85
 		$fileAnalyzeResult = FileAnalysisTool::analyse($imagePath);
86 86
 
87
-		if(null === $fileAnalyzeResult) {
87
+		if (null === $fileAnalyzeResult) {
88 88
 			throw new Exception('could not analyze the file');
89 89
 		}
90 90
 
91
-		if(false === in_array($fileAnalyzeResult->getMimeType(), array(
91
+		if (false === in_array($fileAnalyzeResult->getMimeType(), array(
92 92
 				'image/jpg',
93 93
 				'image/jpeg',
94 94
 				'image/png' ))) {
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 
103 103
 		//encrypt the image file
104 104
 		$encryptionResult = $this->cryptTool->encryptImage(file_get_contents($imagePath), $this->privateKey, $receiverPublicKey);
105
-		$uploadResult =  $this->connection->uploadFile($encryptionResult->getData());
105
+		$uploadResult = $this->connection->uploadFile($encryptionResult->getData());
106 106
 
107
-		if($uploadResult === null || !$uploadResult->isSuccess()) {
107
+		if ($uploadResult === null || !$uploadResult->isSuccess()) {
108 108
 			throw new Exception('could not upload the image ('.$uploadResult->getErrorCode().' '.$uploadResult->getErrorMessage().') '.$uploadResult->getRawResponse());
109 109
 		}
110 110
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		//analyse the file
135 135
 		$fileAnalyzeResult = FileAnalysisTool::analyse($filePath);
136 136
 
137
-		if(null === $fileAnalyzeResult) {
137
+		if (null === $fileAnalyzeResult) {
138 138
 			throw new Exception('could not analyze the file');
139 139
 		}
140 140
 
@@ -145,21 +145,21 @@  discard block
 block discarded – undo
145 145
 
146 146
 		//encrypt the main file
147 147
 		$encryptionResult = $this->cryptTool->encryptFile(file_get_contents($filePath));
148
-		$uploadResult =  $this->connection->uploadFile($encryptionResult->getData());
148
+		$uploadResult = $this->connection->uploadFile($encryptionResult->getData());
149 149
 
150
-		if($uploadResult === null || !$uploadResult->isSuccess()) {
150
+		if ($uploadResult === null || !$uploadResult->isSuccess()) {
151 151
 			throw new Exception('could not upload the file ('.$uploadResult->getErrorCode().' '.$uploadResult->getErrorMessage().') '.$uploadResult->getRawResponse());
152 152
 		}
153 153
 
154 154
 		$thumbnailUploadResult = null;
155 155
 
156 156
 		//encrypt the thumbnail file (if exists)
157
-		if(strlen($thumbnailPath) > 0 && true === file_exists($thumbnailPath)) {
157
+		if (strlen($thumbnailPath) > 0 && true === file_exists($thumbnailPath)) {
158 158
 			//encrypt the main file
159 159
 			$thumbnailEncryptionResult = $this->cryptTool->encryptFileThumbnail(file_get_contents($thumbnailPath), $encryptionResult->getKey());
160 160
 			$thumbnailUploadResult = $this->connection->uploadFile($thumbnailEncryptionResult->getData());
161 161
 
162
-			if($thumbnailUploadResult === null || !$thumbnailUploadResult->isSuccess()) {
162
+			if ($thumbnailUploadResult === null || !$thumbnailUploadResult->isSuccess()) {
163 163
 				throw new Exception('could not upload the thumbnail file ('.$thumbnailUploadResult->getErrorCode().' '.$thumbnailUploadResult->getErrorMessage().') '.$thumbnailUploadResult->getRawResponse());
164 164
 			}
165 165
 		}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		//fetch the public key
210 210
 		$receiverPublicKey = $this->connection->fetchPublicKey($threemaId);
211 211
 
212
-		if(null === $receiverPublicKey || !$receiverPublicKey->isSuccess()) {
212
+		if (null === $receiverPublicKey || !$receiverPublicKey->isSuccess()) {
213 213
 			throw new Exception('Invalid threema id');
214 214
 		}
215 215
 
@@ -220,22 +220,22 @@  discard block
 block discarded – undo
220 220
 			$nonce
221 221
 		);
222 222
 
223
-		if(null === $message || false === is_object($message)) {
223
+		if (null === $message || false === is_object($message)) {
224 224
 			throw new Exception('Could not encrypt box');
225 225
 		}
226 226
 
227
-		if($outputFolder === false) {
227
+		if ($outputFolder === false) {
228 228
 			return $receiveResult;
229 229
 		}
230
-		if($outputFolder === null || strlen($outputFolder) == 0) {
230
+		if ($outputFolder === null || strlen($outputFolder) == 0) {
231 231
 			$outputFolder = '.';
232 232
 		}
233 233
 
234 234
 		$receiveResult = new ReceiveMessageResult($messageId, $message);
235 235
 
236
-		if($message instanceof ImageMessage) {
236
+		if ($message instanceof ImageMessage) {
237 237
 			$result = $this->downloadFile($message, $message->getBlobId(), $downloadMessage);
238
-			if(null !== $result && true === $result->isSuccess()) {
238
+			if (null !== $result && true === $result->isSuccess()) {
239 239
 				$image = $this->cryptTool->decryptImage(
240 240
 					$result->getData(),
241 241
 					$this->cryptTool->hex2bin($receiverPublicKey->getPublicKey()),
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 					throw new Exception('decryption of image failed');
248 248
 				}
249 249
 				//save file
250
-				$filePath = $outputFolder . '/' . $messageId . '.jpg';
250
+				$filePath = $outputFolder.'/'.$messageId.'.jpg';
251 251
 				$f = fopen($filePath, 'w+');
252 252
 				fwrite($f, $image);
253 253
 				fclose($f);
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 				$receiveResult->addFile('image', $filePath);
256 256
 			}
257 257
 		}
258
-		else if($message instanceof FileMessage) {
258
+		else if ($message instanceof FileMessage) {
259 259
 			$result = $this->downloadFile($message, $message->getBlobId(), $downloadMessage);
260 260
 
261
-			if(null !== $result && true === $result->isSuccess()) {
261
+			if (null !== $result && true === $result->isSuccess()) {
262 262
 				$file = $this->cryptTool->decryptFile(
263 263
 					$result->getData(),
264 264
 					hex2bin($message->getEncryptionKey()));
@@ -268,20 +268,20 @@  discard block
 block discarded – undo
268 268
 				}
269 269
 
270 270
 				//save file
271
-				$filePath = $outputFolder . '/' . $messageId . '-' . $message->getFilename();
271
+				$filePath = $outputFolder.'/'.$messageId.'-'.$message->getFilename();
272 272
 				file_put_contents($filePath, $file);
273 273
 
274 274
 				$receiveResult->addFile('file', $filePath);
275 275
 			}
276 276
 
277
-			if(null !== $message->getThumbnailBlobId() && strlen($message->getThumbnailBlobId()) > 0) {
277
+			if (null !== $message->getThumbnailBlobId() && strlen($message->getThumbnailBlobId()) > 0) {
278 278
 				$result = $this->downloadFile($message, $message->getThumbnailBlobId(), $downloadMessage);
279
-				if(null !== $result && true === $result->isSuccess()) {
279
+				if (null !== $result && true === $result->isSuccess()) {
280 280
 					$file = $this->cryptTool->decryptFileThumbnail(
281 281
 						$result->getData(),
282 282
 						$this->cryptTool->hex2bin($message->getEncryptionKey()));
283 283
 
284
-					if(null === $file) {
284
+					if (null === $file) {
285 285
 						throw new Exception('thumbnail decryption failed');
286 286
 					}
287 287
 					//save file
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
 		//fetch the public key
309 309
 		$receiverPublicKey = $this->connection->fetchPublicKey($threemaId);
310 310
 
311
-		if(null === $receiverPublicKey || !$receiverPublicKey->isSuccess()) {
311
+		if (null === $receiverPublicKey || !$receiverPublicKey->isSuccess()) {
312 312
 			throw new Exception('Invalid threema id');
313 313
 		}
314 314
 
315
-		if(null !== $capabilityCheck) {
315
+		if (null !== $capabilityCheck) {
316 316
 			//check capability
317 317
 			$capability = $this->connection->keyCapability($threemaId);
318
-			if(null === $capability || false === $capabilityCheck->__invoke($capability)) {
318
+			if (null === $capability || false === $capabilityCheck->__invoke($capability)) {
319 319
 				throw new Exception('threema id does not have the capability');
320 320
 			}
321 321
 		}
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
 	 * @throws Exception
332 332
 	 */
333 333
 	private final function downloadFile(ThreemaMessage $message, $blobId, \Closure $downloadMessage = null) {
334
-		if(null === $downloadMessage
334
+		if (null === $downloadMessage
335 335
 			|| true === $downloadMessage->__invoke($message, $blobId)) {
336 336
 			//make a download
337 337
 			$result = $this->connection->downloadFile($blobId);
338
-			if(null === $result || false === $result->isSuccess()) {
338
+			if (null === $result || false === $result->isSuccess()) {
339 339
 				throw new Exception('could not download the file with blob id '.$blobId);
340 340
 			}
341 341
 
Please login to merge, or discard this patch.