@@ -1,14 +1,14 @@ |
||
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 |
@@ -97,7 +97,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -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\{ |
15 | 15 | CLIRunner, Crypto\CryptoSodium, Endpoint\TinyCurlEndpoint, GatewayOptions |
@@ -24,11 +24,11 @@ discard block |
||
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 |
@@ -1,14 +1,14 @@ |
||
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 |
@@ -84,7 +84,7 @@ |
||
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 | ####################### |
@@ -20,7 +20,7 @@ discard block |
||
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 |
||
30 | 30 | /** |
31 | 31 | * @var string |
32 | 32 | */ |
33 | - public $storagePath = __DIR__.'/../storage'; |
|
33 | + public $storagePath = __DIR__ . '/../storage'; |
|
34 | 34 | |
35 | 35 | } |
@@ -7,7 +7,7 @@ discard block |
||
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 |
||
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 |
||
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'); |