@@ -22,9 +22,9 @@ |
||
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | $result = $connector->fetchPublicKey('ECHOECHO'); |
| 25 | -if($result->isSuccess()) { |
|
| 26 | - echo 'public key '.$result->getPublicKey() . "\n"; |
|
| 25 | +if ($result->isSuccess()) { |
|
| 26 | + echo 'public key '.$result->getPublicKey()."\n"; |
|
| 27 | 27 | } |
| 28 | 28 | else { |
| 29 | - echo 'error '.$result->getErrorMessage() . "\n"; |
|
| 29 | + echo 'error '.$result->getErrorMessage()."\n"; |
|
| 30 | 30 | } |
@@ -29,7 +29,6 @@ |
||
| 29 | 29 | $result = $connector->sendSimple($receiver, "This is a Test Message"); |
| 30 | 30 | if($result->isSuccess()) { |
| 31 | 31 | echo 'Message ID: '.$result->getMessageId() . "\n"; |
| 32 | -} |
|
| 33 | -else { |
|
| 32 | +} else { |
|
| 34 | 33 | echo 'Error: '.$result->getErrorMessage() . "\n"; |
| 35 | 34 | } |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | $connector = new Connection($settings, $publicKeyStore); |
| 22 | 22 | |
| 23 | 23 | $result = $connector->keyLookupByPhoneNumber('123456789'); |
| 24 | -if($result->isSuccess()) { |
|
| 25 | - echo 'Threema ID found: '.$result->getId() . "\n"; |
|
| 24 | +if ($result->isSuccess()) { |
|
| 25 | + echo 'Threema ID found: '.$result->getId()."\n"; |
|
| 26 | 26 | } |
| 27 | 27 | else { |
| 28 | - echo 'Error: '.$result->getErrorMessage() . "\n"; |
|
| 28 | + echo 'Error: '.$result->getErrorMessage()."\n"; |
|
| 29 | 29 | } |
@@ -29,7 +29,6 @@ |
||
| 29 | 29 | $result = $connector->sendSimple($receiver, "This is a Test Message"); |
| 30 | 30 | if($result->isSuccess()) { |
| 31 | 31 | echo 'Message ID: '.$result->getMessageId() . "\n"; |
| 32 | -} |
|
| 33 | -else { |
|
| 32 | +} else { |
|
| 34 | 33 | echo 'Error: '.$result->getErrorMessage() . "\n"; |
| 35 | 34 | } |
@@ -23,12 +23,12 @@ |
||
| 23 | 23 | $senderPrivateKey = "MY_PUBLIC_KEY_IN_BIN"; |
| 24 | 24 | $filePath = "/path/to/my/file.pdf"; |
| 25 | 25 | |
| 26 | -$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey,$connector); |
|
| 26 | +$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey, $connector); |
|
| 27 | 27 | $result = $e2eHelper->sendFileMessage("TEST1234", $filePath); |
| 28 | 28 | |
| 29 | -if(true === $result->isSuccess()) { |
|
| 30 | - echo 'File Message ID: '.$result->getMessageId() . "\n"; |
|
| 29 | +if (true === $result->isSuccess()) { |
|
| 30 | + echo 'File Message ID: '.$result->getMessageId()."\n"; |
|
| 31 | 31 | } |
| 32 | 32 | else { |
| 33 | - echo 'Error: '.$result->getErrorMessage() . "\n"; |
|
| 33 | + echo 'Error: '.$result->getErrorMessage()."\n"; |
|
| 34 | 34 | } |
@@ -29,7 +29,6 @@ |
||
| 29 | 29 | $result = $connector->sendSimple($receiver, "This is a Test Message"); |
| 30 | 30 | if($result->isSuccess()) { |
| 31 | 31 | echo 'Message ID: '.$result->getMessageId() . "\n"; |
| 32 | -} |
|
| 33 | -else { |
|
| 32 | +} else { |
|
| 34 | 33 | echo 'Error: '.$result->getErrorMessage() . "\n"; |
| 35 | 34 | } |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | |
| 23 | 23 | $senderPrivateKey = "MY_PUBLIC_KEY_IN_BIN"; |
| 24 | 24 | |
| 25 | -$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey,$connector); |
|
| 25 | +$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey, $connector); |
|
| 26 | 26 | $result = $e2eHelper->sendTextMessage("TEST1234", "This is an end-to-end encrypted message"); |
| 27 | 27 | |
| 28 | -if(true === $result->isSuccess()) { |
|
| 29 | - echo 'Message ID: '.$result->getMessageId() . "\n"; |
|
| 28 | +if (true === $result->isSuccess()) { |
|
| 29 | + echo 'Message ID: '.$result->getMessageId()."\n"; |
|
| 30 | 30 | } |
| 31 | 31 | else { |
| 32 | - echo 'Error: '.$result->getErrorMessage() . "\n"; |
|
| 32 | + echo 'Error: '.$result->getErrorMessage()."\n"; |
|
| 33 | 33 | } |
@@ -29,7 +29,6 @@ |
||
| 29 | 29 | $result = $connector->sendSimple($receiver, "This is a Test Message"); |
| 30 | 30 | if($result->isSuccess()) { |
| 31 | 31 | echo 'Message ID: '.$result->getMessageId() . "\n"; |
| 32 | -} |
|
| 33 | -else { |
|
| 32 | +} else { |
|
| 34 | 33 | echo 'Error: '.$result->getErrorMessage() . "\n"; |
| 35 | 34 | } |
@@ -27,9 +27,9 @@ |
||
| 27 | 27 | Receiver::TYPE_ID); |
| 28 | 28 | |
| 29 | 29 | $result = $connector->sendSimple($receiver, "This is a Test Message"); |
| 30 | -if($result->isSuccess()) { |
|
| 31 | - echo 'Message ID: '.$result->getMessageId() . "\n"; |
|
| 30 | +if ($result->isSuccess()) { |
|
| 31 | + echo 'Message ID: '.$result->getMessageId()."\n"; |
|
| 32 | 32 | } |
| 33 | 33 | else { |
| 34 | - echo 'Error: '.$result->getErrorMessage() . "\n"; |
|
| 34 | + echo 'Error: '.$result->getErrorMessage()."\n"; |
|
| 35 | 35 | } |
@@ -29,7 +29,6 @@ |
||
| 29 | 29 | $result = $connector->sendSimple($receiver, "This is a Test Message"); |
| 30 | 30 | if($result->isSuccess()) { |
| 31 | 31 | echo 'Message ID: '.$result->getMessageId() . "\n"; |
| 32 | -} |
|
| 33 | -else { |
|
| 32 | +} else { |
|
| 34 | 33 | echo 'Error: '.$result->getErrorMessage() . "\n"; |
| 35 | 34 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return int |
| 69 | 69 | */ |
| 70 | 70 | public function getAllArgumentsCount() { |
| 71 | - return $this->getRequiredArgumentCount() + (null !== $this->optionalArguments ? count($this->optionalArguments) : 0); |
|
| 71 | + return $this->getRequiredArgumentCount()+(null !== $this->optionalArguments ? count($this->optionalArguments) : 0); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | * @return int |
| 77 | 77 | * @throws \Threema\Core\Exception |
| 78 | 78 | */ |
| 79 | - private function getIndexByPos($pos){ |
|
| 79 | + private function getIndexByPos($pos) { |
|
| 80 | 80 | $i = array_search($pos, $this->requiredArguments); |
| 81 | - if(false === $i) { |
|
| 81 | + if (false === $i) { |
|
| 82 | 82 | $i = array_search($pos, $this->optionalArguments); |
| 83 | - if(false !== $i) { |
|
| 83 | + if (false !== $i) { |
|
| 84 | 84 | $i += count($this->requiredArguments); |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - if(false === $i) { |
|
| 87 | + if (false === $i) { |
|
| 88 | 88 | throw new Exception('argument '.$pos.' not found'); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | $i = $this->getIndexByPos($pos); |
| 101 | 101 | $required = $i < count($this->requiredArguments); |
| 102 | 102 | |
| 103 | - if(false === array_key_exists($i, $this->arguments)) { |
|
| 104 | - if(true === $required) { |
|
| 103 | + if (false === array_key_exists($i, $this->arguments)) { |
|
| 104 | + if (true === $required) { |
|
| 105 | 105 | throw new Exception('no argument at position '.$i.' ('.$pos.')'); |
| 106 | 106 | } |
| 107 | 107 | else { |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | public function getArgumentFile($pos) { |
| 122 | 122 | $i = $this->getIndexByPos($pos); |
| 123 | 123 | |
| 124 | - if(false === is_file($this->arguments[$i])) { |
|
| 124 | + if (false === is_file($this->arguments[$i])) { |
|
| 125 | 125 | throw new Exception('argument '.$i.' is not a file'); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function getArgumentPrivateKey($pos) { |
| 136 | 136 | $content = Common::getPrivateKey($this->getArgumentStringOrFileContent($pos)); |
| 137 | - if(null !== $content) { |
|
| 137 | + if (null !== $content) { |
|
| 138 | 138 | return hex2bin($content); |
| 139 | 139 | } |
| 140 | 140 | return null; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function getArgumentPublicKey($pos) { |
| 148 | 148 | $content = Common::getPublicKey($this->getArgumentStringOrFileContent($pos)); |
| 149 | - if(null !== $content) { |
|
| 149 | + if (null !== $content) { |
|
| 150 | 150 | return hex2bin($content); |
| 151 | 151 | } |
| 152 | 152 | return null; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | private function getArgumentStringOrFileContent($pos) { |
| 160 | 160 | $content = $this->getArgument($pos); |
| 161 | - if(file_exists($content)) { |
|
| 161 | + if (file_exists($content)) { |
|
| 162 | 162 | $content = trim(file_get_contents($content)); |
| 163 | 163 | } |
| 164 | 164 | return $content; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function getArgumentThreemaId($pos) { |
| 172 | 172 | $content = $this->getArgument($pos); |
| 173 | - if(null !== $content && strlen($content) == 8) { |
|
| 173 | + if (null !== $content && strlen($content) == 8) { |
|
| 174 | 174 | return strtoupper($content); |
| 175 | 175 | } |
| 176 | 176 | return null; |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | * @return string |
| 181 | 181 | */ |
| 182 | 182 | protected function readStdIn() { |
| 183 | - $f = fopen( 'php://stdin', 'r' ); |
|
| 183 | + $f = fopen('php://stdin', 'r'); |
|
| 184 | 184 | |
| 185 | 185 | $lines = array(); |
| 186 | - while( $line = trim(fgets($f)) ) { |
|
| 186 | + while ($line = trim(fgets($f))) { |
|
| 187 | 187 | |
| 188 | - if(strlen($line) == 0 || $line == "\n") { |
|
| 188 | + if (strlen($line) == 0 || $line == "\n") { |
|
| 189 | 189 | continue; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $argCount = null !== $this->arguments ? count($this->arguments) : 0; |
| 206 | 206 | |
| 207 | - if($argCount < count($this->requiredArguments)) { |
|
| 207 | + if ($argCount < count($this->requiredArguments)) { |
|
| 208 | 208 | throw new Exception('invalid count of arguments'); |
| 209 | 209 | } |
| 210 | 210 | $this->doRun(); |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | final public function help($shellColors = true) { |
| 218 | 218 | $args = array_merge($this->requiredArguments, $this->optionalArguments); |
| 219 | 219 | |
| 220 | - if(count($args) > 0) { |
|
| 220 | + if (count($args) > 0) { |
|
| 221 | 221 | $colorPrefix = ''; |
| 222 | 222 | $colorPostfix = ''; |
| 223 | - if(true === $shellColors) { |
|
| 223 | + if (true === $shellColors) { |
|
| 224 | 224 | $colorPrefix = "\033[0;36m\033[40m"; |
| 225 | 225 | $colorPostfix = "\033[0m"; |
| 226 | 226 | } |
@@ -103,8 +103,7 @@ |
||
| 103 | 103 | if(false === array_key_exists($i, $this->arguments)) { |
| 104 | 104 | if(true === $required) { |
| 105 | 105 | throw new Exception('no argument at position '.$i.' ('.$pos.')'); |
| 106 | - } |
|
| 107 | - else { |
|
| 106 | + } else { |
|
| 108 | 107 | return null; |
| 109 | 108 | } |
| 110 | 109 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | Common::required($threemaId, $from, $secret); |
| 38 | 38 | |
| 39 | - if(strlen($threemaId) != 8) { |
|
| 39 | + if (strlen($threemaId) != 8) { |
|
| 40 | 40 | throw new Exception('invalid threema id'); |
| 41 | 41 | } |
| 42 | 42 | //define connection settings |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $result = $connector->keyCapability($threemaId); |
| 49 | 49 | Common::required($result); |
| 50 | - if($result->isSuccess()) { |
|
| 50 | + if ($result->isSuccess()) { |
|
| 51 | 51 | Common::l(implode("\n", $result->getCapabilities())); |
| 52 | 52 | } |
| 53 | 53 | else { |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | $storeHandle = fopen($this->file, 'r'); |
| 42 | 42 | if(false === $storeHandle) { |
| 43 | 43 | throw new Exception('could not open file '.$this->file); |
| 44 | - } |
|
| 45 | - else { |
|
| 44 | + } else { |
|
| 46 | 45 | $threemaId = strtoupper($threemaId); |
| 47 | 46 | $publicKey = null; |
| 48 | 47 | while (!feof($storeHandle)) { |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | //create a connection |
| 44 | 44 | $connector = new Connection($settings, $this->publicKeyStore); |
| 45 | 45 | |
| 46 | - $result = $connector->keyLookupByEmail($email);; |
|
| 46 | + $result = $connector->keyLookupByEmail($email); ; |
|
| 47 | 47 | Common::required($result); |
| 48 | - if($result->isSuccess()) { |
|
| 48 | + if ($result->isSuccess()) { |
|
| 49 | 49 | Common::l($result->getId()); |
| 50 | 50 | } |
| 51 | 51 | else { |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | $storeHandle = fopen($this->file, 'r'); |
| 42 | 42 | if(false === $storeHandle) { |
| 43 | 43 | throw new Exception('could not open file '.$this->file); |
| 44 | - } |
|
| 45 | - else { |
|
| 44 | + } else { |
|
| 46 | 45 | $threemaId = strtoupper($threemaId); |
| 47 | 46 | $publicKey = null; |
| 48 | 47 | while (!feof($storeHandle)) { |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | //create a connection |
| 44 | 44 | $connector = new Connection($settings, $this->publicKeyStore); |
| 45 | 45 | |
| 46 | - $result = $connector->keyLookupByPhoneNumber($phoneNo);; |
|
| 46 | + $result = $connector->keyLookupByPhoneNumber($phoneNo); ; |
|
| 47 | 47 | Common::required($result); |
| 48 | - if($result->isSuccess()) { |
|
| 48 | + if ($result->isSuccess()) { |
|
| 49 | 49 | Common::l($result->getId()); |
| 50 | 50 | } |
| 51 | 51 | else { |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | $storeHandle = fopen($this->file, 'r'); |
| 42 | 42 | if(false === $storeHandle) { |
| 43 | 43 | throw new Exception('could not open file '.$this->file); |
| 44 | - } |
|
| 45 | - else { |
|
| 44 | + } else { |
|
| 46 | 45 | $threemaId = strtoupper($threemaId); |
| 47 | 46 | $publicKey = null; |
| 48 | 47 | while (!feof($storeHandle)) { |