@@ -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 | /** |
@@ -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 | - * 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 | |
@@ -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 | |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Interface CLIRunnerInterface |
|
| 4 | - * |
|
| 5 | - * @filesource CLIRunnerInterface.php |
|
| 6 | - * @created 03.04.2016 |
|
| 7 | - * @package chillerlan\Threema |
|
| 8 | - * @author Smiley <[email protected]> |
|
| 9 | - * @copyright 2016 Smiley |
|
| 10 | - * @license MIT |
|
| 11 | - */ |
|
| 3 | + * Interface CLIRunnerInterface |
|
| 4 | + * |
|
| 5 | + * @filesource CLIRunnerInterface.php |
|
| 6 | + * @created 03.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 | |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Class CryptoException |
|
| 4 | - * |
|
| 5 | - * @filesource CryptoException.php |
|
| 6 | - * @created 03.04.2016 |
|
| 7 | - * @package chillerlan\Threema\Crypto |
|
| 8 | - * @author Smiley <[email protected]> |
|
| 9 | - * @copyright 2016 Smiley |
|
| 10 | - * @license MIT |
|
| 11 | - */ |
|
| 3 | + * Class CryptoException |
|
| 4 | + * |
|
| 5 | + * @filesource CryptoException.php |
|
| 6 | + * @created 03.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 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | return $this->log2cli($method->invokeArgs($this, $arguments)); |
| 102 | 102 | } |
| 103 | 103 | catch(GatewayException $gatewayException){ |
| 104 | - return $this->log2cli('ERROR: '.$gatewayException->getMessage()); |
|
| 104 | + return $this->log2cli('ERROR: ' . $gatewayException->getMessage()); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @return string |
| 117 | 117 | */ |
| 118 | 118 | protected function log2cli(string $string):string{ |
| 119 | - return PHP_EOL.wordwrap($string, 78, PHP_EOL).PHP_EOL; |
|
| 119 | + return PHP_EOL . wordwrap($string, 78, PHP_EOL) . PHP_EOL; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | if(isset($p[1])){ |
| 160 | 160 | if($p[0] === 'param'){ |
| 161 | 161 | $p = (explode(' ', trim($p[1]), 3)); |
| 162 | - $name = '<'.trim($p[1], ' $').'>'; |
|
| 162 | + $name = '<' . trim($p[1], ' $') . '>'; |
|
| 163 | 163 | $parsed->paramNames[] = $name; |
| 164 | - $doc = isset($p[2]) ? $name.' '.trim($p[2]) : $name; |
|
| 164 | + $doc = isset($p[2]) ? $name . ' ' . trim($p[2]) : $name; |
|
| 165 | 165 | $parsed->paramDoc[] = $doc; |
| 166 | 166 | } |
| 167 | 167 | else if($p[0] === 'return'){ |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function help():string{ |
| 184 | 184 | // return info in case no command was found |
| 185 | - $help = 'Threema Gateway CLI tool.'.PHP_EOL; |
|
| 186 | - $help .= 'Crypto: '.$this->threemaGateway->cryptoVersion().PHP_EOL.PHP_EOL; |
|
| 185 | + $help = 'Threema Gateway CLI tool.' . PHP_EOL; |
|
| 186 | + $help .= 'Crypto: ' . $this->threemaGateway->cryptoVersion() . PHP_EOL . PHP_EOL; |
|
| 187 | 187 | |
| 188 | 188 | foreach(self::COMMANDS as $command => $method){ |
| 189 | 189 | $comment = $this->reflection->getMethod($method)->getDocComment(); |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | $comment = trim(array_shift($params)); |
| 194 | 194 | $parsed = $this->parseDocBlock($params); |
| 195 | 195 | |
| 196 | - $help .= PHP_EOL.'threema.php '.$command.' '.$parsed->paramNames.PHP_EOL; |
|
| 197 | - $help .= str_repeat('-', strlen($command) + 12).PHP_EOL; |
|
| 198 | - $help .= PHP_EOL.$comment.PHP_EOL; |
|
| 199 | - $help .= PHP_EOL.$parsed->paramDoc.PHP_EOL; |
|
| 200 | - $help .= PHP_EOL.'Returns: '.$parsed->returnDoc.PHP_EOL.PHP_EOL; |
|
| 196 | + $help .= PHP_EOL . 'threema.php ' . $command . ' ' . $parsed->paramNames . PHP_EOL; |
|
| 197 | + $help .= str_repeat('-', strlen($command) + 12) . PHP_EOL; |
|
| 198 | + $help .= PHP_EOL . $comment . PHP_EOL; |
|
| 199 | + $help .= PHP_EOL . $parsed->paramDoc . PHP_EOL; |
|
| 200 | + $help .= PHP_EOL . 'Returns: ' . $parsed->returnDoc . PHP_EOL . PHP_EOL; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | return $help; |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | // @todo: check writable |
| 214 | 214 | if(is_dir(dirname($path))){ |
| 215 | 215 | $bytes = file_put_contents($path, $data); |
| 216 | - return $bytes.' bytes written to: '.$path.PHP_EOL; |
|
| 216 | + return $bytes . ' bytes written to: ' . $path . PHP_EOL; |
|
| 217 | 217 | } |
| 218 | 218 | // or is not writable |
| 219 | - return $path.' does not exist'; // @codeCoverageIgnore |
|
| 219 | + return $path . ' does not exist'; // @codeCoverageIgnore |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | public function getKeypair(string $privateKeyFile = null, string $publicKeyFile = null):string{ |
| 226 | 226 | $keypair = $this->cryptoInterface->getKeypair(); |
| 227 | 227 | $message = !empty($privateKeyFile) ? $this->writeFile($privateKeyFile, $keypair->privateKey) : ''; |
| 228 | - $message .= !empty($publicKeyFile) ? $this->writeFile($publicKeyFile, $keypair->publicKey) : ''; |
|
| 228 | + $message .= !empty($publicKeyFile) ? $this->writeFile($publicKeyFile, $keypair->publicKey) : ''; |
|
| 229 | 229 | |
| 230 | - return $message.PHP_EOL.'private:'.$keypair->privateKey.PHP_EOL.'public:'.$keypair->publicKey; |
|
| 230 | + return $message . PHP_EOL . 'private:' . $keypair->privateKey . PHP_EOL . 'public:' . $keypair->publicKey; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function encryptFile(string $privateKey, string $publicKey, string $plaintextFile, string $encryptedFile):string{ |
| 286 | 286 | $encrypted = $this->cryptoInterface->encrypt(file_get_contents($plaintextFile), $privateKey, $publicKey); |
| 287 | - return $this->writeFile($encryptedFile, $encrypted->nonce."\n".$encrypted->box); |
|
| 287 | + return $this->writeFile($encryptedFile, $encrypted->nonce . "\n" . $encrypted->box); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |