Completed
Pull Request — master (#36)
by rugk
02:38
created
source/Threema/MsgApi/Tools/CryptToolSalt.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @return null|string
49 49
 	 */
50 50
 	protected function openBox($box, $recipientPrivateKey, $senderPublicKey, $nonce) {
51
-		$boxPad = str_repeat("\x00", 16) . $box;
51
+		$boxPad = str_repeat("\x00", 16).$box;
52 52
 		try {
53 53
 			$data = Salt::box_open($boxPad, $recipientPrivateKey, $senderPublicKey, $nonce);
54 54
 		} catch (\SaltException $e) {
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @return string as binary
72 72
 	 */
73 73
 	protected function openSecretBox($box, $nonce, $key) {
74
-		$boxPad = str_repeat("\x00", 16) . $box;
74
+		$boxPad = str_repeat("\x00", 16).$box;
75 75
 		$data = Salt::secretbox_open($boxPad, $nonce, $key);
76 76
 
77 77
 		if ($data) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			Salt::decodeInput($nonce),
131 131
 			$key);
132 132
 
133
-		if($data === false) {
133
+		if ($data === false) {
134 134
 			throw new Exception('encryption failed');
135 135
 		}
136 136
 
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 * @throws Exception
153 153
 	 */
154 154
 	public function validate() {
155
-		if(false === $this->isSupported()) {
155
+		if (false === $this->isSupported()) {
156 156
 			throw new Exception('SALT implementation not supported');
157 157
 		}
158 158
 
159
-		if(PHP_INT_SIZE < 8) {
159
+		if (PHP_INT_SIZE < 8) {
160 160
 			throw new Exception('Pure PHP Crypto implementation requires 64Bit PHP. Please install the libsodium PHP extension.');
161 161
 		}
162 162
 		return true;
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/MsgApi/Tools/CryptToolSodiumDep.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@
 block discarded – undo
124 124
 	 * @throws Exception
125 125
 	 */
126 126
 	public function validate() {
127
-		if(false === $this->isSupported()) {
127
+		if (false === $this->isSupported()) {
128 128
 			throw new Exception('Sodium implementation not supported');
129 129
 		}
130 130
 		return true;
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/MsgApi/Tools/FileAnalysisTool.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	public static function analyse($file) {
16 16
 		//check if file exists
17
-		if(false === file_exists($file)) {
17
+		if (false === file_exists($file)) {
18 18
 			return null;
19 19
 		}
20 20
 
21 21
 		//is not a file
22
-		if(false === is_file($file)) {
22
+		if (false === is_file($file)) {
23 23
 			return null;
24 24
 		}
25 25
 
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
 
29 29
 		$mimeType = null;
30 30
 		//mime type getter
31
-		if(function_exists('finfo_open')) {
31
+		if (function_exists('finfo_open')) {
32 32
 			$finfo = finfo_open(FILEINFO_MIME_TYPE);
33 33
 			$mimeType = finfo_file($finfo, $file);
34 34
 		}
35
-		else if(function_exists('mime_content_type')) {
35
+		else if (function_exists('mime_content_type')) {
36 36
 			$mimeType = mime_content_type($file);
37 37
 		}
38 38
 
39 39
 		//default mime type
40
-		if(strlen($mimeType) == 0) {
40
+		if (strlen($mimeType) == 0) {
41 41
 			//default mime type
42 42
 			$mimeType = 'application/octet-stream';
43 43
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@
 block discarded – undo
31 31
 		if(function_exists('finfo_open')) {
32 32
 			$finfo = finfo_open(FILEINFO_MIME_TYPE);
33 33
 			$mimeType = finfo_file($finfo, $file);
34
-		}
35
-		else if(function_exists('mime_content_type')) {
34
+		} else if(function_exists('mime_content_type')) {
36 35
 			$mimeType = mime_content_type($file);
37 36
 		}
38 37
 
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/bootstrap.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 	$fileName  = '';
10 10
 	if ($lastNsPos = strrpos($className, '\\')) {
11 11
 		$namespace = substr($className, 0, $lastNsPos);
12
-		$className = substr($className, $lastNsPos + 1);
13
-		$fileName  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
12
+		$className = substr($className, $lastNsPos+1);
13
+		$fileName  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR;
14 14
 	}
15
-	$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
15
+	$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
16 16
 
17
-	if(true === file_exists( $d.'/'.$fileName)) {
17
+	if (true === file_exists($d.'/'.$fileName)) {
18 18
 		require $d.'/'.$fileName;
19 19
 	}
20 20
 });
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 define('MSGAPI_SDK_VERSION', $sdkVersion);
24 24
 $cryptTool = Threema\MsgApi\Tools\CryptTool::getInstance();
25 25
 
26
-if(null === $cryptTool) {
26
+if (null === $cryptTool) {
27 27
 	throw new \Threema\Core\Exception("no supported crypt-tool");
28 28
 }
29 29
 
Please login to merge, or discard this patch.
threema-msgapi-tool.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 //disallow using the cli tool in a web project
9 9
 if ('cli' !== php_sapi_name() || null === $argv) {
10 10
 	//file not called from the cli
11
-	die('please run ' . basename(__FILE__) . ' only in a cli. '.
11
+	die('please run '.basename(__FILE__).' only in a cli. '.
12 12
 		'To use the threema msgapi sdk in your web project, include the source/bootstrap.php or the threema_msgapi.phar file.');
13 13
 }
14 14
 try {
@@ -20,6 +20,6 @@  discard block
 block discarded – undo
20 20
 		Threema\MsgApi\PublicKeyStores\PhpFile::create('keystore.php'));
21 21
 	$tool->run();
22 22
 } catch (\Threema\Core\Exception $exception) {
23
-	echo "ERROR: " . $exception->getMessage() . "\n";
23
+	echo "ERROR: ".$exception->getMessage()."\n";
24 24
 	die();
25 25
 }
Please login to merge, or discard this patch.
source/Threema/Console/Command/Credits.php 3 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.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/Console/Command/LookupPublicKeyById.php 3 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.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/Console/Command/SendE2EFile.php 3 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.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/Console/Command/SendE2EText.php 3 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.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.