@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param string $subject |
49 | 49 | * @param string[] $requiredArguments |
50 | 50 | * @param string $description |
51 | - * @param array $optionalArguments |
|
51 | + * @param string[] $optionalArguments |
|
52 | 52 | */ |
53 | 53 | public function __construct($subject, array $requiredArguments, $description, array $optionalArguments = array()) { |
54 | 54 | $this->subject = $subject; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * return a valid file path |
116 | 116 | * |
117 | 117 | * @param string $pos |
118 | - * @return null|string |
|
118 | + * @return string |
|
119 | 119 | * @throws \Threema\Core\Exception |
120 | 120 | */ |
121 | 121 | public function getArgumentFile($pos) { |
@@ -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 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Threema GmbH |
|
4 | - * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | - */ |
|
3 | + * @author Threema GmbH |
|
4 | + * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | |
8 | 8 | namespace Threema\MsgApi\Tools; |
@@ -36,8 +36,8 @@ |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * @param $string |
|
40 | - * @param array|null $requiredKeys |
|
39 | + * @param string $string |
|
40 | + * @param string[] $requiredKeys |
|
41 | 41 | * @return AssocArray |
42 | 42 | * @throws Exception |
43 | 43 | */ |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return mixed|null return the key value or the default value |
29 | 29 | */ |
30 | 30 | public function getValue($key, $defaultValue = null) { |
31 | - if(false === array_key_exists($key, $this->data)) { |
|
31 | + if (false === array_key_exists($key, $this->data)) { |
|
32 | 32 | return $defaultValue; |
33 | 33 | } |
34 | 34 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static final function byJsonString($string, array $requiredKeys = null) { |
45 | 45 | $v = json_decode($string, true); |
46 | - if(null === $v || false === $v) { |
|
46 | + if (null === $v || false === $v) { |
|
47 | 47 | throw new Exception('invalid json string'); |
48 | 48 | } |
49 | 49 | |
50 | 50 | //validate first |
51 | - if(null !== $requiredKeys) { |
|
51 | + if (null !== $requiredKeys) { |
|
52 | 52 | //validate array first |
53 | - foreach($requiredKeys as $requiredKey) { |
|
54 | - if(false === array($v)) { |
|
53 | + foreach ($requiredKeys as $requiredKey) { |
|
54 | + if (false === array($v)) { |
|
55 | 55 | throw new Exception('required key '.$requiredKey.' failed'); |
56 | 56 | } |
57 | 57 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Threema GmbH |
|
4 | - * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | - */ |
|
3 | + * @author Threema GmbH |
|
4 | + * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | |
8 | 8 | namespace Threema\MsgApi\Tools; |
@@ -40,7 +40,7 @@ |
||
40 | 40 | /** |
41 | 41 | * @param int $httpCode |
42 | 42 | * @param object $res |
43 | - * @return UploadFileResult |
|
43 | + * @return DownloadFileResult |
|
44 | 44 | */ |
45 | 45 | function parseResult($httpCode, $res){ |
46 | 46 | return new DownloadFileResult($httpCode, $res); |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Threema GmbH |
|
4 | - * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | - */ |
|
3 | + * @author Threema GmbH |
|
4 | + * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | |
8 | 8 | namespace Threema\MsgApi\Tools; |
@@ -48,7 +48,7 @@ |
||
48 | 48 | * @param object $res |
49 | 49 | * @return UploadFileResult |
50 | 50 | */ |
51 | - function parseResult($httpCode, $res){ |
|
51 | + function parseResult($httpCode, $res) { |
|
52 | 52 | return new UploadFileResult($httpCode, $res); |
53 | 53 | } |
54 | 54 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | - * @return \string[] |
|
76 | + * @return string[] |
|
77 | 77 | */ |
78 | 78 | public function getErrors() { |
79 | 79 | return $this->errors; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * @return \string[] |
|
90 | + * @return string[] |
|
91 | 91 | */ |
92 | 92 | public function getFiles() { |
93 | 93 | return $this->files; |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Threema GmbH |
|
4 | - * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | - */ |
|
3 | + * @author Threema GmbH |
|
4 | + * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | |
8 | 8 | namespace Threema\MsgApi\Tools; |
@@ -65,7 +65,7 @@ |
||
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Get the acknowledged message ids |
68 | - * @return array |
|
68 | + * @return string[] |
|
69 | 69 | */ |
70 | 70 | public function getAckedMessageIds() { |
71 | 71 | return $this->ackedMessageIds; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @return string |
58 | 58 | */ |
59 | 59 | public function getReceiptTypeName() { |
60 | - if(true === array_key_exists($this->receiptType, self::$receiptTypesToNames)) { |
|
60 | + if (true === array_key_exists($this->receiptType, self::$receiptTypesToNames)) { |
|
61 | 61 | return self::$receiptTypesToNames[$this->receiptType]; |
62 | 62 | } |
63 | 63 | return null; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return string |
78 | 78 | */ |
79 | 79 | function __toString() { |
80 | - $str = "Delivery receipt (" . $this->getReceiptTypeName() . "): "; |
|
80 | + $str = "Delivery receipt (".$this->getReceiptTypeName()."): "; |
|
81 | 81 | $hexMessageIds = array(); |
82 | 82 | foreach ($this->ackedMessageIds as $messageId) { |
83 | 83 | $hexMessageIds[] = bin2hex($messageId); |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Threema GmbH |
|
4 | - * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | - */ |
|
3 | + * @author Threema GmbH |
|
4 | + * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | |
8 | 8 | namespace Threema\MsgApi\Tools; |
@@ -142,6 +142,11 @@ discard block |
||
142 | 142 | return $this->makeBox($message, $nonce, $senderPrivateKey, $recipientPublicKey); |
143 | 143 | } |
144 | 144 | |
145 | + /** |
|
146 | + * @param string $senderPrivateKey |
|
147 | + * @param string $recipientPublicKey |
|
148 | + * @param string $nonce |
|
149 | + */ |
|
145 | 150 | final public function encryptFileMessage(UploadFileResult $uploadFileResult, |
146 | 151 | EncryptResult $encryptResult, |
147 | 152 | UploadFileResult $thumbnailUploadFileResult = null, |
@@ -190,9 +195,9 @@ discard block |
||
190 | 195 | * make a secret box |
191 | 196 | * |
192 | 197 | * @param $data |
193 | - * @param $nonce |
|
198 | + * @param string $nonce |
|
194 | 199 | * @param $key |
195 | - * @return mixed |
|
200 | + * @return string |
|
196 | 201 | */ |
197 | 202 | abstract protected function makeSecretBox($data, $nonce, $key); |
198 | 203 | |
@@ -376,7 +381,7 @@ discard block |
||
376 | 381 | abstract public function validate(); |
377 | 382 | |
378 | 383 | /** |
379 | - * @param $data |
|
384 | + * @param string $data |
|
380 | 385 | * @return EncryptResult |
381 | 386 | */ |
382 | 387 | public final function encryptFile($data) { |
@@ -388,7 +393,7 @@ discard block |
||
388 | 393 | /** |
389 | 394 | * @param string $data as binary |
390 | 395 | * @param string $key as binary |
391 | - * @return null|string |
|
396 | + * @return string |
|
392 | 397 | */ |
393 | 398 | public final function decryptFile($data, $key) { |
394 | 399 | $result = $this->openSecretBox($data, self::FILE_NONCE, $key); |
@@ -405,6 +410,10 @@ discard block |
||
405 | 410 | return new EncryptResult($box, $key, self::FILE_THUMBNAIL_NONCE, strlen($box)); |
406 | 411 | } |
407 | 412 | |
413 | + /** |
|
414 | + * @param string $data |
|
415 | + * @param string $key |
|
416 | + */ |
|
408 | 417 | public final function decryptFileThumbnail($data, $key) { |
409 | 418 | $result = $this->openSecretBox($data, self::FILE_THUMBNAIL_NONCE, $key); |
410 | 419 | return false === $result ? null : $result; |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @return CryptTool |
43 | 43 | */ |
44 | 44 | public static function getInstance() { |
45 | - if(null === self::$instance) { |
|
46 | - foreach(array( |
|
45 | + if (null === self::$instance) { |
|
46 | + foreach (array( |
|
47 | 47 | function() { |
48 | 48 | return self::createInstance(self::TYPE_SODIUM); |
49 | 49 | }, |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return self::createInstance(self::TYPE_SALT); |
52 | 52 | }) as $instanceGenerator) { |
53 | 53 | $i = $instanceGenerator->__invoke(); |
54 | - if(null !== $i) { |
|
54 | + if (null !== $i) { |
|
55 | 55 | self::$instance = $i; |
56 | 56 | break; |
57 | 57 | } |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | * @return null|CryptTool null on unknown type |
67 | 67 | */ |
68 | 68 | public static function createInstance($type) { |
69 | - switch($type) { |
|
69 | + switch ($type) { |
|
70 | 70 | case self::TYPE_SODIUM: |
71 | 71 | $instance = new CryptToolSodium(); |
72 | - if(false === $instance->isSupported()) { |
|
72 | + if (false === $instance->isSupported()) { |
|
73 | 73 | //try to instance old version of sodium wrapper |
74 | 74 | /** @noinspection PhpDeprecationInspection */ |
75 | 75 | $instance = new CryptToolSodiumDep(); |
76 | 76 | } |
77 | - return $instance->isSupported() ? $instance :null; |
|
77 | + return $instance->isSupported() ? $instance : null; |
|
78 | 78 | case self::TYPE_SALT: |
79 | 79 | $instance = new CryptToolSalt(); |
80 | - return $instance->isSupported() ? $instance :null; |
|
80 | + return $instance->isSupported() ? $instance : null; |
|
81 | 81 | default: |
82 | 82 | return null; |
83 | 83 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | final public function encryptMessageText($text, $senderPrivateKey, $recipientPublicKey, $nonce) { |
106 | 106 | /* prepend type byte (0x01) to message data */ |
107 | - $textBytes = "\x01" . $text; |
|
107 | + $textBytes = "\x01".$text; |
|
108 | 108 | |
109 | 109 | /* determine random amount of PKCS7 padding */ |
110 | 110 | $padbytes = mt_rand(1, 255); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $senderPrivateKey, |
130 | 130 | $recipientPublicKey, |
131 | 131 | $nonce) { |
132 | - $message = "\x02" . hex2bin($uploadFileResult->getBlobId()); |
|
132 | + $message = "\x02".hex2bin($uploadFileResult->getBlobId()); |
|
133 | 133 | $message .= pack('V', $encryptResult->getSize()); |
134 | 134 | $message .= $encryptResult->getNonce(); |
135 | 135 | |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | 'i' => 0 |
161 | 161 | ); |
162 | 162 | |
163 | - if($thumbnailUploadFileResult != null && strlen($thumbnailUploadFileResult->getBlobId()) > 0) { |
|
163 | + if ($thumbnailUploadFileResult != null && strlen($thumbnailUploadFileResult->getBlobId()) > 0) { |
|
164 | 164 | $messageContent['t'] = $thumbnailUploadFileResult->getBlobId(); |
165 | 165 | } |
166 | 166 | |
167 | - $message = "\x17" . json_encode($messageContent); |
|
167 | + $message = "\x17".json_encode($messageContent); |
|
168 | 168 | |
169 | 169 | /* determine random amount of PKCS7 padding */ |
170 | 170 | $padbytes = mt_rand(1, 255); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | /* remove padding */ |
239 | 239 | $padbytes = ord($data[strlen($data)-1]); |
240 | - $realDataLength = strlen($data) - $padbytes; |
|
240 | + $realDataLength = strlen($data)-$padbytes; |
|
241 | 241 | if ($realDataLength < 1) { |
242 | 242 | throw new BadMessageException(); |
243 | 243 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | return new TextMessage(substr($data, 1)); |
264 | 264 | case DeliveryReceipt::TYPE_CODE: |
265 | 265 | /* Delivery receipt */ |
266 | - if ($realDataLength < (self::MESSAGE_ID_LEN-2) || (($realDataLength - 2) % self::MESSAGE_ID_LEN) != 0) { |
|
266 | + if ($realDataLength < (self::MESSAGE_ID_LEN-2) || (($realDataLength-2)%self::MESSAGE_ID_LEN) != 0) { |
|
267 | 267 | throw new BadMessageException(); |
268 | 268 | } |
269 | 269 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | return new DeliveryReceipt($receiptType, $messageIds); |
274 | 274 | case ImageMessage::TYPE_CODE: |
275 | 275 | /* Image Message */ |
276 | - if ($realDataLength != 1 + self::BLOB_ID_LEN + self::IMAGE_FILE_SIZE_LEN + self::IMAGE_NONCE_LEN) { |
|
276 | + if ($realDataLength != 1+self::BLOB_ID_LEN+self::IMAGE_FILE_SIZE_LEN+self::IMAGE_NONCE_LEN) { |
|
277 | 277 | throw new BadMessageException(); |
278 | 278 | } |
279 | 279 | |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | case FileMessage::TYPE_CODE: |
285 | 285 | /* Image Message */ |
286 | 286 | $decodeResult = json_decode(substr($data, 1), true); |
287 | - if(null === $decodeResult || false === $decodeResult) { |
|
287 | + if (null === $decodeResult || false === $decodeResult) { |
|
288 | 288 | throw new BadMessageException(); |
289 | 289 | } |
290 | 290 | |
291 | 291 | $values = AssocArray::byJsonString(substr($data, 1), array('b', 't', 'k', 'm', 'n', 's')); |
292 | - if(null === $values) { |
|
292 | + if (null === $values) { |
|
293 | 293 | throw new BadMessageException(); |
294 | 294 | } |
295 | 295 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @return null|string |
392 | 392 | */ |
393 | 393 | public final function decryptFile($data, $key) { |
394 | - $result = $this->openSecretBox($data, self::FILE_NONCE, $key); |
|
394 | + $result = $this->openSecretBox($data, self::FILE_NONCE, $key); |
|
395 | 395 | return false === $result ? null : $result; |
396 | 396 | } |
397 | 397 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public final function encryptFileThumbnail($data, $key) { |
404 | 404 | $box = $this->makeSecretBox($data, self::FILE_THUMBNAIL_NONCE, $key); |
405 | - return new EncryptResult($box, $key, self::FILE_THUMBNAIL_NONCE, strlen($box)); |
|
405 | + return new EncryptResult($box, $key, self::FILE_THUMBNAIL_NONCE, strlen($box)); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | public final function decryptFileThumbnail($data, $key) { |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Threema GmbH |
|
4 | - * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | - */ |
|
3 | + * @author Threema GmbH |
|
4 | + * @copyright Copyright (c) 2015 Threema GmbH |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | |
8 | 8 | namespace Threema\MsgApi\Tools; |
@@ -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 | } |