Completed
Push — master ( 9b0d18...fb03b4 )
by smiley
02:39
created
src/Crypto/CryptoSodium.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	public function version():string{
23 23
 		/** @noinspection PhpUndefinedNamespaceInspection @noinspection PhpUndefinedFunctionInspection */
24
-		return 'libsodium '.\Sodium\version_string();
24
+		return 'libsodium ' . \Sodium\version_string();
25 25
 	}
26 26
 
27 27
 	/**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			throw new CryptoException('invalid data');
78 78
 		}
79 79
 
80
-		if(!preg_match('/^[a-f\d]{128}$/i', $privateKey.$publicKey)){
80
+		if(!preg_match('/^[a-f\d]{128}$/i', $privateKey . $publicKey)){
81 81
 			throw new CryptoException('invalid keypair');
82 82
 		}
83 83
 
Please login to merge, or discard this patch.
src/GatewayException.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Class GatewayException
4
- *
5
- * @filesource   GatewayException.php
6
- * @created      02.04.2016
7
- * @package      chillerlan\Threema
8
- * @author       Smiley <[email protected]>
9
- * @copyright    2016 Smiley
10
- * @license      MIT
11
- */
3
+	 * Class GatewayException
4
+	 *
5
+	 * @filesource   GatewayException.php
6
+	 * @created      02.04.2016
7
+	 * @package      chillerlan\Threema
8
+	 * @author       Smiley <[email protected]>
9
+	 * @copyright    2016 Smiley
10
+	 * @license      MIT
11
+	 */
12 12
 
13 13
 namespace chillerlan\Threema;
14 14
 
Please login to merge, or discard this patch.
src/Crypto/CryptoAbstract.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Class CryptoAbstract
4
- *
5
- * @filesource   CryptoAbstract.php
6
- * @created      02.04.2016
7
- * @package      chillerlan\Threema\Crypto
8
- * @author       Smiley <[email protected]>
9
- * @copyright    2016 Smiley
10
- * @license      MIT
11
- */
3
+	 * Class CryptoAbstract
4
+	 *
5
+	 * @filesource   CryptoAbstract.php
6
+	 * @created      02.04.2016
7
+	 * @package      chillerlan\Threema\Crypto
8
+	 * @author       Smiley <[email protected]>
9
+	 * @copyright    2016 Smiley
10
+	 * @license      MIT
11
+	 */
12 12
 
13 13
 namespace chillerlan\Threema\Crypto;
14 14
 
Please login to merge, or discard this patch.
src/CLIRunner.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Class CLIRunner
4
- *
5
- * @filesource   CLIRunner.php
6
- * @created      01.04.2016
7
- * @package      chillerlan\Threema
8
- * @author       Smiley <[email protected]>
9
- * @copyright    2016 Smiley
10
- * @license      MIT
11
- */
3
+	 * Class CLIRunner
4
+	 *
5
+	 * @filesource   CLIRunner.php
6
+	 * @created      01.04.2016
7
+	 * @package      chillerlan\Threema
8
+	 * @author       Smiley <[email protected]>
9
+	 * @copyright    2016 Smiley
10
+	 * @license      MIT
11
+	 */
12 12
 
13 13
 namespace chillerlan\Threema;
14 14
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				return $this->log2cli($method->invokeArgs($this, $arguments));
98 98
 			}
99 99
 			catch(GatewayException $gatewayException){
100
-				return $this->log2cli('ERROR: '.$gatewayException->getMessage());
100
+				return $this->log2cli('ERROR: ' . $gatewayException->getMessage());
101 101
 			}
102 102
 		}
103 103
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @return string
113 113
 	 */
114 114
 	protected function log2cli(string $string):string{
115
-		return PHP_EOL.wordwrap($string, 78, PHP_EOL).PHP_EOL;
115
+		return PHP_EOL . wordwrap($string, 78, PHP_EOL) . PHP_EOL;
116 116
 	}
117 117
 
118 118
 	/**
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 			if(isset($p[1])){
156 156
 				if($p[0] === 'param'){
157 157
 					$p                    = (explode(' ', trim($p[1]), 3));
158
-					$name                 = '<'.trim($p[1], ' $').'>';
158
+					$name                 = '<' . trim($p[1], ' $') . '>';
159 159
 					$parsed->paramNames[] = $name;
160
-					$doc                  = isset($p[2]) ? $name.' '.trim($p[2]) : $name;
160
+					$doc                  = isset($p[2]) ? $name . ' ' . trim($p[2]) : $name;
161 161
 					$parsed->paramDoc[]   = $doc;
162 162
 				}
163 163
 				else if($p[0] === 'return'){
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	public function help():string{
180 180
 		// return info in case no command was found
181
-		$help = 'Threema Gateway CLI tool.'.PHP_EOL;
182
-		$help .= 'Crypto: '.$this->cryptoInterface->version().PHP_EOL.PHP_EOL;
181
+		$help = 'Threema Gateway CLI tool.' . PHP_EOL;
182
+		$help .= 'Crypto: ' . $this->cryptoInterface->version() . PHP_EOL . PHP_EOL;
183 183
 
184 184
 		foreach(self::COMMANDS as $command => $method){
185 185
 			$comment = $this->reflection->getMethod($method)->getDocComment();
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 			$comment = trim(array_shift($params));
190 190
 			$parsed  = $this->parseDocBlock($params);
191 191
 
192
-			$help .= PHP_EOL.'threema.php '.$command.' '.$parsed->paramNames.PHP_EOL;
193
-			$help .= str_repeat('-', strlen($command) + 12).PHP_EOL;
194
-			$help .= PHP_EOL.$comment.PHP_EOL;
195
-			$help .= PHP_EOL.$parsed->paramDoc.PHP_EOL;
196
-			$help .= PHP_EOL.'Returns: '.$parsed->returnDoc.PHP_EOL.PHP_EOL;
192
+			$help .= PHP_EOL . 'threema.php ' . $command . ' ' . $parsed->paramNames . PHP_EOL;
193
+			$help .= str_repeat('-', strlen($command) + 12) . PHP_EOL;
194
+			$help .= PHP_EOL . $comment . PHP_EOL;
195
+			$help .= PHP_EOL . $parsed->paramDoc . PHP_EOL;
196
+			$help .= PHP_EOL . 'Returns: ' . $parsed->returnDoc . PHP_EOL . PHP_EOL;
197 197
 		}
198 198
 
199 199
 		return $help;
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 		// @todo: check writable
210 210
 		if(is_dir(dirname($path))){
211 211
 			$bytes = file_put_contents($path, $data);
212
-			return $bytes.' bytes written to: '.$path.PHP_EOL;
212
+			return $bytes . ' bytes written to: ' . $path . PHP_EOL;
213 213
 		}
214 214
 		// or is not writable
215
-		return $path.' does not exist'; // @codeCoverageIgnore
215
+		return $path . ' does not exist'; // @codeCoverageIgnore
216 216
 	}
217 217
 
218 218
 	/**
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	public function getKeypair(string $privateKeyFile = null, string $publicKeyFile = null):string{
222 222
 		$keypair  = $this->cryptoInterface->getKeypair();
223 223
 		$message  = !empty($privateKeyFile) ? $this->writeFile($privateKeyFile, $keypair->privateKey) : '';
224
-		$message .= !empty($publicKeyFile)  ? $this->writeFile($publicKeyFile, $keypair->publicKey)   : '';
224
+		$message .= !empty($publicKeyFile) ? $this->writeFile($publicKeyFile, $keypair->publicKey) : '';
225 225
 
226
-		return $message.PHP_EOL.'private:'.$keypair->privateKey.PHP_EOL.'public:'.$keypair->publicKey;
226
+		return $message . PHP_EOL . 'private:' . $keypair->privateKey . PHP_EOL . 'public:' . $keypair->publicKey;
227 227
 	}
228 228
 
229 229
 	/**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 */
281 281
 	public function encryptFile(string $privateKey, string $publicKey, string $plaintextFile, string $encryptedFile):string{
282 282
 		$encrypted = $this->cryptoInterface->encrypt(file_get_contents($plaintextFile), $privateKey, $publicKey);
283
-		return $this->writeFile($encryptedFile, $encrypted->nonce."\n".$encrypted->box);
283
+		return $this->writeFile($encryptedFile, $encrypted->nonce . "\n" . $encrypted->box);
284 284
 	}
285 285
 
286 286
 	/**
Please login to merge, or discard this patch.
src/Endpoint/TinyCurlEndpoint.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@
 block discarded – undo
198 198
 	}
199 199
 
200 200
 	/**
201
-	 * @param $email
201
+	 * @param string $email
202 202
 	 *
203 203
 	 * @return string
204 204
 	 * @throws \chillerlan\Threema\GatewayException
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Class TinyCurlEndpoint
4
- *
5
- * @filesource   TinyCurlEndpoint.php
6
- * @created      02.04.2016
7
- * @package      chillerlan\Threema\Endpoint
8
- * @author       Smiley <[email protected]>
9
- * @copyright    2016 Smiley
10
- * @license      MIT
11
- */
3
+	 * Class TinyCurlEndpoint
4
+	 *
5
+	 * @filesource   TinyCurlEndpoint.php
6
+	 * @created      02.04.2016
7
+	 * @package      chillerlan\Threema\Endpoint
8
+	 * @author       Smiley <[email protected]>
9
+	 * @copyright    2016 Smiley
10
+	 * @license      MIT
11
+	 */
12 12
 
13 13
 namespace chillerlan\Threema\Endpoint;
14 14
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @throws \chillerlan\TinyCurl\RequestException
66 66
 	 */
67 67
 	protected function getResponse(string $endpoint, array $params = [], array $body = []):Response{
68
-		$endpoint = self::API_BASE.$endpoint;
68
+		$endpoint = self::API_BASE . $endpoint;
69 69
 		$params   = array_merge($params, [
70 70
 			'from'   => getenv('THREEMA_GATEWAY_ID'),
71 71
 			'secret' => getenv('THREEMA_GATEWAY_SECRET')
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 			return $response;
82 82
 		}
83 83
 		elseif(array_key_exists($response->info->http_code, self::API_ERRORS)){
84
-			throw new GatewayException('gateway error: '.self::API_ERRORS[$response->info->http_code]);
84
+			throw new GatewayException('gateway error: ' . self::API_ERRORS[$response->info->http_code]);
85 85
 		}
86 86
 
87 87
 		throw new GatewayException('unknown error: "compiles on my machine."'); // @codeCoverageIgnore
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @inheritdoc
99 99
 	 */
100 100
 	public function checkCapabilities(string $threemaID):array{
101
-		$response = $this->getResponse('/capabilities/'.$this->checkThreemaID($threemaID))->body->content;
101
+		$response = $this->getResponse('/capabilities/' . $this->checkThreemaID($threemaID))->body->content;
102 102
 		$response = !empty($response) ? explode(',', $response) : [];
103 103
 
104 104
 		sort($response);
@@ -110,35 +110,35 @@  discard block
 block discarded – undo
110 110
 	 * @inheritdoc
111 111
 	 */
112 112
 	public function getIdByPhone(string $phoneno):string{
113
-		return $this->getResponse('/lookup/phone/'.$this->checkPhoneNo($phoneno))->body->content;
113
+		return $this->getResponse('/lookup/phone/' . $this->checkPhoneNo($phoneno))->body->content;
114 114
 	}
115 115
 
116 116
 	/**
117 117
 	 * @inheritdoc
118 118
 	 */
119 119
 	public function getIdByPhoneHash(string $phonenoHash):string{
120
-		return $this->getResponse('/lookup/phone_hash/'.$this->checkHash($phonenoHash))->body->content;
120
+		return $this->getResponse('/lookup/phone_hash/' . $this->checkHash($phonenoHash))->body->content;
121 121
 	}
122 122
 
123 123
 	/**
124 124
 	 * @inheritdoc
125 125
 	 */
126 126
 	public function getIdByEmail(string $email):string{
127
-		return $this->getResponse('/lookup/email/'.$this->checkEmail($email))->body->content;
127
+		return $this->getResponse('/lookup/email/' . $this->checkEmail($email))->body->content;
128 128
 	}
129 129
 
130 130
 	/**
131 131
 	 * @inheritdoc
132 132
 	 */
133 133
 	public function getIdByEmailHash(string $emailHash):string{
134
-		return $this->getResponse('/lookup/email_hash/'.$this->checkHash($emailHash))->body->content;
134
+		return $this->getResponse('/lookup/email_hash/' . $this->checkHash($emailHash))->body->content;
135 135
 	}
136 136
 
137 137
 	/**
138 138
 	 * @inheritdoc
139 139
 	 */
140 140
 	public function getPublicKey(string $threemaID):string{
141
-		return $this->checkHash($this->getResponse('/pubkeys/'.$this->checkThreemaID($threemaID))->body->content);
141
+		return $this->checkHash($this->getResponse('/pubkeys/' . $this->checkThreemaID($threemaID))->body->content);
142 142
 	}
143 143
 
144 144
 	/**
Please login to merge, or discard this patch.
cli/threema.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 namespace chillerlan\ThreemaCLI;
11 11
 
12
-require_once __DIR__.'/../vendor/autoload.php';
12
+require_once __DIR__ . '/../vendor/autoload.php';
13 13
 
14 14
 use chillerlan\Threema\{
15 15
 	CLIRunner, Crypto\CryptoSodium, Endpoint\TinyCurlEndpoint, GatewayOptions
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 
25 25
 $gatewayOptions                 = new GatewayOptions;
26 26
 $gatewayOptions->configFilename = '.threema'; // @todo TRAVIS REMINDER!
27
-$gatewayOptions->configPath     = __DIR__.'/../config';
28
-$gatewayOptions->storagePath    = __DIR__.'/../storage';
27
+$gatewayOptions->configPath     = __DIR__ . '/../config';
28
+$gatewayOptions->storagePath    = __DIR__ . '/../storage';
29 29
 
30 30
 $requestOptions          = new RequestOptions;
31
-$requestOptions->ca_info = __DIR__.'/../storage/cacert.pem'; // https://curl.haxx.se/ca/cacert.pem
31
+$requestOptions->ca_info = __DIR__ . '/../storage/cacert.pem'; // https://curl.haxx.se/ca/cacert.pem
32 32
 
33 33
 $CLIRunner = new CLIRunner(new TinyCurlEndpoint($gatewayOptions, new Request($requestOptions)), new CryptoSodium);
34 34
 
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 			return $reflectionMethod->invokeArgs($this->endpointInterface, $params);
85 85
 		}
86 86
 
87
-		throw new GatewayException('method "'.$method.'" does not exist');
87
+		throw new GatewayException('method "' . $method . '" does not exist');
88 88
 	}
89 89
 
90 90
 	#######################
Please login to merge, or discard this patch.
src/GatewayOptions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * @var string
22 22
 	 */
23
-	public $configPath = __DIR__.'/../config';
23
+	public $configPath = __DIR__ . '/../config';
24 24
 
25 25
 	/**
26 26
 	 * @var string
@@ -30,6 +30,6 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * @var string
32 32
 	 */
33
-	public $storagePath = __DIR__.'/../storage';
33
+	public $storagePath = __DIR__ . '/../storage';
34 34
 
35 35
 }
Please login to merge, or discard this patch.
public/gateway.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @license      MIT
8 8
  */
9 9
 
10
-require_once __DIR__.'/../vendor/autoload.php';
10
+require_once __DIR__ . '/../vendor/autoload.php';
11 11
 
12 12
 use chillerlan\Threema\{
13 13
 	Crypto\CryptoSodium, Endpoint\TinyCurlEndpoint, Gateway, GatewayOptions
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 
19 19
 $gatewayOptions                 = new GatewayOptions;
20 20
 $gatewayOptions->configFilename = '.threema'; // @todo TRAVIS REMINDER!
21
-$gatewayOptions->configPath     = __DIR__.'/../config';
22
-$gatewayOptions->storagePath    = __DIR__.'/../storage';
21
+$gatewayOptions->configPath     = __DIR__ . '/../config';
22
+$gatewayOptions->storagePath    = __DIR__ . '/../storage';
23 23
 
24 24
 $requestOptions          = new RequestOptions;
25
-$requestOptions->ca_info = __DIR__.'/../storage/cacert.pem'; // https://curl.haxx.se/ca/cacert.pem
25
+$requestOptions->ca_info = __DIR__ . '/../storage/cacert.pem'; // https://curl.haxx.se/ca/cacert.pem
26 26
 
27 27
 $gateway = new Gateway(new TinyCurlEndpoint($gatewayOptions, new Request($requestOptions)), new CryptoSodium);
28 28
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 }
40 40
 
41 41
 header('Content-type: application/json;charset=utf-8;');
42
-header('Last-Modified: '.date('r'));
42
+header('Last-Modified: ' . date('r'));
43 43
 header('Expires: Tue, 23 May 1989 13:37:23 GMT');
44 44
 header('Cache-Control: max-age=0, private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
45 45
 header('Pragma: no-cache');
Please login to merge, or discard this patch.