@@ -12,9 +12,9 @@ |
||
12 | 12 | |
13 | 13 | namespace chillerlan\Threema; |
14 | 14 | |
15 | -use chillerlan\Threema\Crypto\CryptoInterface; |
|
16 | 15 | use ReflectionClass; |
17 | 16 | use ReflectionMethod; |
17 | +use chillerlan\Threema\Crypto\CryptoInterface; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | return $this->log2cli($method->invokeArgs($this, $arguments)); |
107 | 107 | } |
108 | 108 | catch(GatewayException $gatewayException){ |
109 | - return $this->log2cli('ERROR: '.$gatewayException->getMessage()); |
|
109 | + return $this->log2cli('ERROR: ' . $gatewayException->getMessage()); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return string |
122 | 122 | */ |
123 | 123 | protected function log2cli(string $string):string{ |
124 | - return PHP_EOL.wordwrap($string, 78, PHP_EOL).PHP_EOL; |
|
124 | + return PHP_EOL . wordwrap($string, 78, PHP_EOL) . PHP_EOL; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | if(isset($p[1])){ |
165 | 165 | if($p[0] === 'param'){ |
166 | 166 | $p = (explode(' ', trim($p[1]), 3)); |
167 | - $name = '<'.trim($p[1], ' $').'>'; |
|
167 | + $name = '<' . trim($p[1], ' $') . '>'; |
|
168 | 168 | $parsed->paramNames[] = $name; |
169 | - $doc = isset($p[2]) ? $name.' '.trim($p[2]) : $name; |
|
169 | + $doc = isset($p[2]) ? $name . ' ' . trim($p[2]) : $name; |
|
170 | 170 | $parsed->paramDoc[] = $doc; |
171 | 171 | } |
172 | 172 | else if($p[0] === 'return'){ |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function help():string{ |
189 | 189 | // return info in case no command was found |
190 | - $help = 'Threema Gateway CLI tool.'.PHP_EOL; |
|
191 | - $help .= 'Crypto: '.$this->threemaGateway->cryptoVersion().PHP_EOL.PHP_EOL; |
|
190 | + $help = 'Threema Gateway CLI tool.' . PHP_EOL; |
|
191 | + $help .= 'Crypto: ' . $this->threemaGateway->cryptoVersion() . PHP_EOL . PHP_EOL; |
|
192 | 192 | |
193 | 193 | foreach(self::COMMANDS as $command => $method){ |
194 | 194 | $comment = $this->reflection->getMethod($method)->getDocComment(); |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | $comment = trim(array_shift($params)); |
199 | 199 | $parsed = $this->parseDocBlock($params); |
200 | 200 | |
201 | - $help .= PHP_EOL.'threema.php '.$command.' '.$parsed->paramNames.PHP_EOL; |
|
202 | - $help .= str_repeat('-', strlen($command) + 12).PHP_EOL; |
|
203 | - $help .= PHP_EOL.$comment.PHP_EOL; |
|
204 | - $help .= PHP_EOL.$parsed->paramDoc.PHP_EOL; |
|
205 | - $help .= PHP_EOL.'Returns: '.$parsed->returnDoc.PHP_EOL.PHP_EOL; |
|
201 | + $help .= PHP_EOL . 'threema.php ' . $command . ' ' . $parsed->paramNames . PHP_EOL; |
|
202 | + $help .= str_repeat('-', strlen($command) + 12) . PHP_EOL; |
|
203 | + $help .= PHP_EOL . $comment . PHP_EOL; |
|
204 | + $help .= PHP_EOL . $parsed->paramDoc . PHP_EOL; |
|
205 | + $help .= PHP_EOL . 'Returns: ' . $parsed->returnDoc . PHP_EOL . PHP_EOL; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return $help; |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | // @todo: check writable |
219 | 219 | if(!empty($privateKeyFile) && is_dir(dirname($privateKeyFile))){ |
220 | 220 | file_put_contents($privateKeyFile, $keypair->privateKey); |
221 | - $message .= 'Private key saved to: '.$privateKeyFile.PHP_EOL; |
|
221 | + $message .= 'Private key saved to: ' . $privateKeyFile . PHP_EOL; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if(!empty($publicKeyFile) && is_dir(dirname($publicKeyFile))){ |
225 | 225 | file_put_contents($publicKeyFile, $keypair->publicKey); |
226 | - $message .= 'Public key saved to: '.$publicKeyFile.PHP_EOL; |
|
226 | + $message .= 'Public key saved to: ' . $publicKeyFile . PHP_EOL; |
|
227 | 227 | } |
228 | 228 | |
229 | - return $message.PHP_EOL.'private:'.$keypair->privateKey.PHP_EOL.'public:'.$keypair->publicKey; |
|
229 | + return $message . PHP_EOL . 'private:' . $keypair->privateKey . PHP_EOL . 'public:' . $keypair->publicKey; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -21,7 +21,7 @@ discard block |
||
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 |
||
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 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $reflectionClass = new ReflectionClass($gatewayOptions->gatewayInterface); |
73 | 73 | |
74 | 74 | if(!$reflectionClass->implementsInterface(GatewayInterface::class)){ |
75 | - throw new GatewayException('"'.$gatewayOptions->gatewayInterface.'" does not implement GatewayInterface'); |
|
75 | + throw new GatewayException('"' . $gatewayOptions->gatewayInterface . '" does not implement GatewayInterface'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $this->gatewayInterface = $reflectionClass->newInstanceArgs([$cryptoInterface, $gatewayOptions]); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | return $reflectionMethod->invokeArgs($this->gatewayInterface, $params); |
94 | 94 | } |
95 | 95 | |
96 | - throw new GatewayException('method "'.$method.'" does not exist'); |
|
96 | + throw new GatewayException('method "' . $method . '" does not exist'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | ####################### |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Class Gateway |
|
4 | - * |
|
5 | - * @filesource Gateway.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 Gateway |
|
4 | + * |
|
5 | + * @filesource Gateway.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 |
@@ -65,7 +65,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Class GatewayEndpoint |
|
4 | - * |
|
5 | - * @filesource GatewayEndpoint.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 GatewayEndpoint |
|
4 | + * |
|
5 | + * @filesource GatewayEndpoint.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 |
@@ -198,7 +198,7 @@ |
||
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 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * @var string |
27 | 27 | */ |
28 | - public $configPath = __DIR__.'/../config'; |
|
28 | + public $configPath = __DIR__ . '/../config'; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @var string |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var string |
37 | 37 | */ |
38 | - public $storagePath = __DIR__.'/../storage'; |
|
38 | + public $storagePath = __DIR__ . '/../storage'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * full path to the CA Root Certificates for use with CURL/SSL |
@@ -43,6 +43,6 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @var string |
45 | 45 | */ |
46 | - public $cacert = __DIR__.'/../storage/cacert.pem'; |
|
46 | + public $cacert = __DIR__ . '/../storage/cacert.pem'; |
|
47 | 47 | |
48 | 48 | } |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Interface GatewayInterface |
|
4 | - * |
|
5 | - * @filesource GatewayInterface.php |
|
6 | - * @created 01.04.2016 |
|
7 | - * @package chillerlan\Threema |
|
8 | - * @author Smiley <[email protected]> |
|
9 | - * @copyright 2016 Smiley |
|
10 | - * @license MIT |
|
11 | - */ |
|
3 | + * Interface GatewayInterface |
|
4 | + * |
|
5 | + * @filesource GatewayInterface.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 |
@@ -9,7 +9,7 @@ discard block |
||
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\CLIRunner; |
15 | 15 | use chillerlan\Threema\Crypto\CryptoSodium; |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | |
22 | 22 | $gatewayOptions = new GatewayOptions; |
23 | 23 | $gatewayOptions->configFilename = '.threema'; // @todo TRAVIS REMINDER! |
24 | -$gatewayOptions->configPath = __DIR__.'/../config'; |
|
25 | -$gatewayOptions->storagePath = __DIR__.'/../storage'; |
|
26 | -$gatewayOptions->cacert = __DIR__.'/../storage/cacert.pem'; |
|
24 | +$gatewayOptions->configPath = __DIR__ . '/../config'; |
|
25 | +$gatewayOptions->storagePath = __DIR__ . '/../storage'; |
|
26 | +$gatewayOptions->cacert = __DIR__ . '/../storage/cacert.pem'; |
|
27 | 27 | |
28 | 28 | echo (new CLIRunner(new CryptoSodium, $gatewayOptions))->run($_SERVER['argv']); |
29 | 29 |