@@ -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 | * |
@@ -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 |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return $this->log2cli($method->invokeArgs($this, $arguments)); |
104 | 104 | } |
105 | 105 | catch(GatewayException $gatewayException){ |
106 | - return $this->log2cli('ERROR: '.$gatewayException->getMessage()); |
|
106 | + return $this->log2cli('ERROR: ' . $gatewayException->getMessage()); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return string |
119 | 119 | */ |
120 | 120 | protected function log2cli(string $string):string{ |
121 | - return PHP_EOL.wordwrap($string, 78, PHP_EOL).PHP_EOL; |
|
121 | + return PHP_EOL . wordwrap($string, 78, PHP_EOL) . PHP_EOL; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function help():string{ |
148 | 148 | // return info in case no command was found |
149 | - $help = 'Threema Gateway CLI tool.'.PHP_EOL; |
|
150 | - $help .= 'Crypto: '.$this->threemaGateway->cryptoVersion().PHP_EOL.PHP_EOL; |
|
149 | + $help = 'Threema Gateway CLI tool.' . PHP_EOL; |
|
150 | + $help .= 'Crypto: ' . $this->threemaGateway->cryptoVersion() . PHP_EOL . PHP_EOL; |
|
151 | 151 | |
152 | 152 | foreach(self::COMMANDS as $command => $method){ |
153 | 153 | $comment = $this->reflection->getMethod($method)->getDocComment(); |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | if(isset($p[1])){ |
166 | 166 | if($p[0] === 'param'){ |
167 | 167 | $p = (explode(' ', trim($p[1]), 3)); |
168 | - $name = '<'.trim($p[1], ' $').'>'; |
|
168 | + $name = '<' . trim($p[1], ' $') . '>'; |
|
169 | 169 | $paramNames[] = $name; |
170 | - $doc = isset($p[2]) ? $name.' '.trim($p[2]) : $name; |
|
170 | + $doc = isset($p[2]) ? $name . ' ' . trim($p[2]) : $name; |
|
171 | 171 | $paramDoc[] = $doc; |
172 | 172 | } |
173 | 173 | else if($p[0] === 'return'){ |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - $help .= PHP_EOL.'threema.php '.$command.' '.implode(' ', $paramNames).PHP_EOL; |
|
183 | - $help .= str_repeat('-', strlen($command)+12).PHP_EOL; |
|
184 | - $help .= PHP_EOL.$comment.PHP_EOL; |
|
185 | - $help .= PHP_EOL.implode(PHP_EOL, $paramDoc).PHP_EOL; |
|
186 | - $help .= PHP_EOL.'Returns: '.$returnDoc.PHP_EOL.PHP_EOL; |
|
182 | + $help .= PHP_EOL . 'threema.php ' . $command . ' ' . implode(' ', $paramNames) . PHP_EOL; |
|
183 | + $help .= str_repeat('-', strlen($command) + 12) . PHP_EOL; |
|
184 | + $help .= PHP_EOL . $comment . PHP_EOL; |
|
185 | + $help .= PHP_EOL . implode(PHP_EOL, $paramDoc) . PHP_EOL; |
|
186 | + $help .= PHP_EOL . 'Returns: ' . $returnDoc . PHP_EOL . PHP_EOL; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return $help; |
@@ -198,15 +198,15 @@ discard block |
||
198 | 198 | |
199 | 199 | if(is_dir(dirname($privateKeyFile))){ |
200 | 200 | file_put_contents($privateKeyFile, $keypair->privateKey); |
201 | - $message .= 'Private key saved to: '.$privateKeyFile.PHP_EOL; |
|
201 | + $message .= 'Private key saved to: ' . $privateKeyFile . PHP_EOL; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | if(is_dir(dirname($publicKeyFile))){ |
205 | 205 | file_put_contents($publicKeyFile, $keypair->publicKey); |
206 | - $message .= 'Public key saved to: '.$publicKeyFile.PHP_EOL; |
|
206 | + $message .= 'Public key saved to: ' . $publicKeyFile . PHP_EOL; |
|
207 | 207 | } |
208 | 208 | |
209 | - return $message.PHP_EOL.'private:'.$keypair->privateKey.PHP_EOL.'public:'.$keypair->publicKey; |
|
209 | + return $message . PHP_EOL . 'private:' . $keypair->privateKey . PHP_EOL . 'public:' . $keypair->publicKey; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -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 | ####################### |
@@ -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 | /** |
@@ -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 | - * Class GatewayOptions |
|
4 | - * |
|
5 | - * @filesource GatewayOptions.php |
|
6 | - * @created 02.04.2016 |
|
7 | - * @package chillerlan\Threema\Containers |
|
8 | - * @author Smiley <[email protected]> |
|
9 | - * @copyright 2016 Smiley |
|
10 | - * @license MIT |
|
11 | - */ |
|
3 | + * Class GatewayOptions |
|
4 | + * |
|
5 | + * @filesource GatewayOptions.php |
|
6 | + * @created 02.04.2016 |
|
7 | + * @package chillerlan\Threema\Containers |
|
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 |