@@ -24,10 +24,10 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function createNotification($format, $alert, array $options = array(), $tagsOrTagExpression = '', \DateTime $scheduleTime = null) |
| 26 | 26 | { |
| 27 | - $class = __NAMESPACE__ . '\\' . ucfirst($format) . 'Notification'; |
|
| 27 | + $class = __NAMESPACE__.'\\'.ucfirst($format).'Notification'; |
|
| 28 | 28 | |
| 29 | 29 | if (!class_exists($class)) { |
| 30 | - throw new \RuntimeException('Invalid format: ' . $format); |
|
| 30 | + throw new \RuntimeException('Invalid format: '.$format); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | return new $class($alert, $options, $tagsOrTagExpression, $scheduleTime); |
@@ -49,17 +49,17 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $headers = array( |
| 52 | - 'Content-Type: ' . $this->getContentType(), |
|
| 53 | - 'ServiceBusNotification-Format: ' . $this->getFormat() |
|
| 52 | + 'Content-Type: '.$this->getContentType(), |
|
| 53 | + 'ServiceBusNotification-Format: '.$this->getFormat() |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | if ('' !== $tagExpression) { |
| 57 | - $headers[] = 'ServiceBusNotification-Tags: ' . $tagExpression; |
|
| 57 | + $headers[] = 'ServiceBusNotification-Tags: '.$tagExpression; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if ($this->scheduleTime instanceof \DateTime) { |
| 61 | 61 | $this->scheduleTime->setTimeZone(new \DateTimeZone('UTC')); |
| 62 | - $headers[] = 'ServiceBusNotification-ScheduleTime: ' . $this->scheduleTime->format(self::SCHEDULE_TIME_FORMAT); |
|
| 62 | + $headers[] = 'ServiceBusNotification-ScheduleTime: '.$this->scheduleTime->format(self::SCHEDULE_TIME_FORMAT); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return $headers; |
@@ -71,22 +71,22 @@ discard block |
||
| 71 | 71 | public function buildUri($endpoint, $hubPath) |
| 72 | 72 | { |
| 73 | 73 | if ($this->scheduleTime instanceof \DateTime) { |
| 74 | - return $endpoint . $hubPath . '/schedulednotifications/'; |
|
| 74 | + return $endpoint.$hubPath.'/schedulednotifications/'; |
|
| 75 | 75 | } |
| 76 | - return $endpoint . $hubPath . '/messages/'; |
|
| 76 | + return $endpoint.$hubPath.'/messages/'; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * {@inheritdoc} |
| 81 | 81 | */ |
| 82 | - public function setToken($deviceToken){ |
|
| 82 | + public function setToken($deviceToken) { |
|
| 83 | 83 | $this->deviceToken = $deviceToken; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * {@inheritdoc} |
| 88 | 88 | */ |
| 89 | - public function getToken(){ |
|
| 89 | + public function getToken() { |
|
| 90 | 90 | return $this->deviceToken; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | public function createRegistration($type) |
| 22 | 22 | { |
| 23 | - $class = __NAMESPACE__ . '\\' . ucfirst($type) . 'Registration'; |
|
| 23 | + $class = __NAMESPACE__.'\\'.ucfirst($type).'Registration'; |
|
| 24 | 24 | |
| 25 | 25 | if (!class_exists($class)) { |
| 26 | - throw new \RuntimeException('Invalid type: ' . $type); |
|
| 26 | + throw new \RuntimeException('Invalid type: '.$type); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return new $class; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function buildUri($endpoint, $hubPath) |
| 157 | 157 | { |
| 158 | - $uri = $endpoint . $hubPath . '/registrations/'; |
|
| 158 | + $uri = $endpoint.$hubPath.'/registrations/'; |
|
| 159 | 159 | |
| 160 | 160 | if ($this->registrationId) { |
| 161 | 161 | $uri .= $this->registrationId; |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | public function getHeaders() |
| 179 | 179 | { |
| 180 | 180 | $headers = array( |
| 181 | - 'Content-Type: ' . $this->getContentType(), |
|
| 182 | - 'x-ms-version: ' . '2015-01' |
|
| 181 | + 'Content-Type: '.$this->getContentType(), |
|
| 182 | + 'x-ms-version: '.'2015-01' |
|
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | if ($this->eTag) { |
| 186 | - $headers[] = 'If-Match: ' . $this->eTag; |
|
| 186 | + $headers[] = 'If-Match: '.$this->eTag; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return $headers; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | $description = $dom->getElementsByTagName($descriptionTag)->item(0); |
| 299 | 299 | if (!$description) { |
| 300 | - throw new \RuntimeException("Could not find '" . $descriptionTag . "' tag in the response: " . $response); |
|
| 300 | + throw new \RuntimeException("Could not find '".$descriptionTag."' tag in the response: ".$response); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | $result = array(); |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $parts = explode(";", $connectionString); |
| 50 | 50 | if (sizeof($parts) != 3) { |
| 51 | - throw new \RuntimeException("Error parsing connection string: " . $connectionString); |
|
| 51 | + throw new \RuntimeException("Error parsing connection string: ".$connectionString); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | foreach ($parts as $part) { |
| 55 | 55 | if (strpos($part, "Endpoint") === 0) { |
| 56 | - $this->endpoint = "https" . substr($part, 11); |
|
| 56 | + $this->endpoint = "https".substr($part, 11); |
|
| 57 | 57 | } else if (strpos($part, "SharedAccessKeyName") === 0) { |
| 58 | 58 | $this->sasKeyName = substr($part, 20); |
| 59 | 59 | } else if (strpos($part, "SharedAccessKey") === 0) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | if (!$this->endpoint || !$this->sasKeyName || !$this->sasKeyValue) { |
| 65 | - throw new \RuntimeException("Invalid connection string: " . $connectionString); |
|
| 65 | + throw new \RuntimeException("Invalid connection string: ".$connectionString); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | $expires = time(); |
| 80 | 80 | $expiresInMins = 60; |
| 81 | 81 | $expires = $expires + $expiresInMins * 60; |
| 82 | - $toSign = $targetUri . "\n" . $expires; |
|
| 82 | + $toSign = $targetUri."\n".$expires; |
|
| 83 | 83 | $signature = rawurlencode(base64_encode(hash_hmac('sha256', $toSign, $this->sasKeyValue, TRUE))); |
| 84 | - $token = "SharedAccessSignature sr=" . $targetUri . "&sig=" . $signature . "&se=" . $expires . "&skn=" . $this->sasKeyName; |
|
| 84 | + $token = "SharedAccessSignature sr=".$targetUri."&sig=".$signature."&se=".$expires."&skn=".$this->sasKeyName; |
|
| 85 | 85 | |
| 86 | 86 | return $token; |
| 87 | 87 | } |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function sendNotification(NotificationInterface $notification) |
| 97 | 97 | { |
| 98 | - $uri = $notification->buildUri($this->endpoint, $this->hubPath). self::API_VERSION; |
|
| 98 | + $uri = $notification->buildUri($this->endpoint, $this->hubPath).self::API_VERSION; |
|
| 99 | 99 | |
| 100 | 100 | $token = $this->generateSasToken($uri); |
| 101 | 101 | |
| 102 | - $headers = array_merge(['Authorization: ' . $token], $notification->getHeaders()); |
|
| 102 | + $headers = array_merge(['Authorization: '.$token], $notification->getHeaders()); |
|
| 103 | 103 | |
| 104 | 104 | $this->request(self::METHOD_POST, $uri, $headers, $notification->getPayload()); |
| 105 | 105 | } |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | public function sendNotificationWithToken(NotificationInterface $notification) |
| 115 | 115 | { |
| 116 | 116 | // $uri = $notification->buildUri($this->endpoint, $this->hubPath). '?direct&api-version=2015-01'; |
| 117 | - $uri = $notification->buildUri($this->endpoint, $this->hubPath). '?direct' . self::API_VERSION; |
|
| 117 | + $uri = $notification->buildUri($this->endpoint, $this->hubPath).'?direct'.self::API_VERSION; |
|
| 118 | 118 | |
| 119 | 119 | $token = $this->generateSasToken($uri); |
| 120 | 120 | |
| 121 | 121 | $headers = array_merge([ |
| 122 | - 'Authorization: ' . $token, |
|
| 123 | - 'ServiceBusNotification-DeviceHandle: ' . $notification->getToken(), |
|
| 122 | + 'Authorization: '.$token, |
|
| 123 | + 'ServiceBusNotification-DeviceHandle: '.$notification->getToken(), |
|
| 124 | 124 | ], |
| 125 | 125 | $notification->getHeaders() |
| 126 | 126 | ); |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | throw new \RuntimeException('Registration ID and ETag must be empty.'); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $uri = $registration->buildUri($this->endpoint, $this->hubPath) . self::API_VERSION; |
|
| 146 | + $uri = $registration->buildUri($this->endpoint, $this->hubPath).self::API_VERSION; |
|
| 147 | 147 | |
| 148 | 148 | $token = $this->generateSasToken($uri); |
| 149 | - $headers = array_merge(array('Authorization: ' . $token), $registration->getHeaders()); |
|
| 149 | + $headers = array_merge(array('Authorization: '.$token), $registration->getHeaders()); |
|
| 150 | 150 | |
| 151 | 151 | // $testing = ["uri" => $uri, "headers" => $headers]; |
| 152 | 152 | // return $testing; |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | throw new \RuntimeException('Registration ID is mandatory.'); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $uri = $registration->buildUri($this->endpoint, $this->hubPath) . self::API_VERSION; |
|
| 174 | + $uri = $registration->buildUri($this->endpoint, $this->hubPath).self::API_VERSION; |
|
| 175 | 175 | |
| 176 | 176 | $token = $this->generateSasToken($uri); |
| 177 | - $headers = array_merge(array('Authorization: ' . $token), $registration->getHeaders()); |
|
| 177 | + $headers = array_merge(array('Authorization: '.$token), $registration->getHeaders()); |
|
| 178 | 178 | |
| 179 | 179 | $response = $this->request(self::METHOD_PUT, $uri, $headers, $registration->getPayload()); |
| 180 | 180 | |
@@ -196,10 +196,10 @@ discard block |
||
| 196 | 196 | throw new \RuntimeException('Registration ID and ETag are mandatory.'); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - $uri = $registration->buildUri($this->endpoint, $this->hubPath) . self::API_VERSION; |
|
| 199 | + $uri = $registration->buildUri($this->endpoint, $this->hubPath).self::API_VERSION; |
|
| 200 | 200 | |
| 201 | 201 | $token = $this->generateSasToken($uri); |
| 202 | - $headers = array_merge(array('Authorization: ' . $token), $registration->getHeaders()); |
|
| 202 | + $headers = array_merge(array('Authorization: '.$token), $registration->getHeaders()); |
|
| 203 | 203 | |
| 204 | 204 | $this->request(self::METHOD_DELETE, $uri, $headers); |
| 205 | 205 | } |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | throw new \RuntimeException('Registration ID is mandatory.'); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $uri = $registration->buildUri($this->endpoint, $this->hubPath) . self::API_VERSION; |
|
| 222 | + $uri = $registration->buildUri($this->endpoint, $this->hubPath).self::API_VERSION; |
|
| 223 | 223 | |
| 224 | 224 | $token = $this->generateSasToken($uri); |
| 225 | - $headers = array_merge(array('Authorization: ' . $token), $registration->getHeaders()); |
|
| 225 | + $headers = array_merge(array('Authorization: '.$token), $registration->getHeaders()); |
|
| 226 | 226 | |
| 227 | 227 | $response = $this->request(self::METHOD_GET, $uri, $headers); |
| 228 | 228 | |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | throw new \RuntimeException('Token is mandatory.'); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $uri = $registration->buildUri($this->endpoint, $this->hubPath) . self::API_VERSION . |
|
| 248 | - '&$filter=' . urlencode($registration->getTokenTag() . ' eq \'' . $registration->getToken() . '\''); |
|
| 247 | + $uri = $registration->buildUri($this->endpoint, $this->hubPath).self::API_VERSION. |
|
| 248 | + '&$filter='.urlencode($registration->getTokenTag().' eq \''.$registration->getToken().'\''); |
|
| 249 | 249 | |
| 250 | 250 | $token = $this->generateSasToken($uri); |
| 251 | - $headers = array_merge(array('Authorization: ' . $token), $registration->getHeaders()); |
|
| 251 | + $headers = array_merge(array('Authorization: '.$token), $registration->getHeaders()); |
|
| 252 | 252 | |
| 253 | 253 | $response = $this->request(self::METHOD_GET, $uri, $headers); |
| 254 | 254 | |
@@ -273,16 +273,16 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $registration = new GcmRegistration(); |
| 275 | 275 | // build uri |
| 276 | - $uri = $this->endpoint . $this->hubPath . "/registrationIDs/"; |
|
| 276 | + $uri = $this->endpoint.$this->hubPath."/registrationIDs/"; |
|
| 277 | 277 | |
| 278 | 278 | $token = $this->generateSasToken($uri); |
| 279 | - $headers = array_merge(array('Authorization: ' . $token), $registration->getHeaders()); |
|
| 279 | + $headers = array_merge(array('Authorization: '.$token), $registration->getHeaders()); |
|
| 280 | 280 | $headers = array_merge(array('Content-length: 0'), $headers); |
| 281 | 281 | |
| 282 | - $response = $this->request(self::METHOD_POST, $uri . self::API_VERSION, $headers, null, true); |
|
| 282 | + $response = $this->request(self::METHOD_POST, $uri.self::API_VERSION, $headers, null, true); |
|
| 283 | 283 | |
| 284 | 284 | preg_match( |
| 285 | - '#' . $uri . '([^?]+)' . preg_quote(self::API_VERSION) . '#', |
|
| 285 | + '#'.$uri.'([^?]+)'.preg_quote(self::API_VERSION).'#', |
|
| 286 | 286 | $response, |
| 287 | 287 | $matches |
| 288 | 288 | ); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | $info = curl_getinfo($ch); |
| 334 | 334 | if ($info['http_code'] != 200 && $info['http_code'] != 201) { |
| 335 | - throw new \RuntimeException('Error sending request: ' . $info['http_code'] . ' msg: ' . $response); |
|
| 335 | + throw new \RuntimeException('Error sending request: '.$info['http_code'].' msg: '.$response); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | return $response; |