| @@ -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 | } | 
| @@ -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); | 
| @@ -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; | 
| @@ -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); | 
| @@ -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 | } | 
| @@ -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 | } | 
| @@ -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 | } | 
| @@ -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 | } | 
| @@ -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 | } |