@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $url = $this->_options["url"]."?appId=".$this->_options["appid"]; |
| 42 | 42 | |
| 43 | - $url.= "¬ificationToken=".$notificationToken; |
|
| 43 | + $url .= "¬ificationToken=".$notificationToken; |
|
| 44 | 44 | |
| 45 | 45 | $ch = curl_init(); |
| 46 | 46 | |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | $output = curl_exec($ch); |
| 54 | 54 | curl_close($ch); |
| 55 | 55 | |
| 56 | - if (stripos($output, "not found")!==false) { |
|
| 56 | + if (stripos($output, "not found") !== false) { |
|
| 57 | 57 | $this->logger->error('Token Exchange failed and responded with: not found', ['full output' => $output]); |
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (stripos($output, "error")!==false) { |
|
| 61 | + if (stripos($output, "error") !== false) { |
|
| 62 | 62 | $this->logger->error('Token Exchange failed and responded with: error', ['full output' => $output]); |
| 63 | 63 | return false; |
| 64 | 64 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @throws \Google\Exception |
| 52 | 52 | * @throws Tiqr_Message_Exception_SendFailure |
| 53 | 53 | */ |
| 54 | - private function getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir ) |
|
| 54 | + private function getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir) |
|
| 55 | 55 | { |
| 56 | 56 | $client = new \Google_Client(); |
| 57 | 57 | // Try to add a file based cache for accesstokens, if configured |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $pool = new FilesystemCachePool($filesystem); |
| 63 | 63 | |
| 64 | 64 | //set up a callback to log token refresh |
| 65 | - $tokenCallback = function ($cacheKey, $accessToken) { |
|
| 65 | + $tokenCallback = function($cacheKey, $accessToken) { |
|
| 66 | 66 | $this->logger->debug(sprintf('New access token received at cache key %s', $cacheKey)); |
| 67 | 67 | }; |
| 68 | 68 | $client->setTokenCallback($tokenCallback); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param $retry boolean is this a 2nd attempt |
| 91 | 91 | * @throws Tiqr_Message_Exception_SendFailure |
| 92 | 92 | */ |
| 93 | - private function _sendFirebase(string $deviceToken, string $alert, string $challenge, string $projectId, string $credentialsFile, bool $cacheTokens, string $tokenCacheDir, bool $retry=false) |
|
| 93 | + private function _sendFirebase(string $deviceToken, string $alert, string $challenge, string $projectId, string $credentialsFile, bool $cacheTokens, string $tokenCacheDir, bool $retry = false) |
|
| 94 | 94 | { |
| 95 | 95 | $apiurl = 'https://fcm.googleapis.com/v1/projects/'.$projectId.'/messages:send'; |
| 96 | 96 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | try { |
| 111 | 111 | $headers = array( |
| 112 | - 'Authorization: Bearer ' . $this->getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir), |
|
| 112 | + 'Authorization: Bearer '.$this->getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir), |
|
| 113 | 113 | 'Content-Type: application/json', |
| 114 | 114 | ); |
| 115 | 115 | } catch (\Google\Exception $e) { |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if (!empty($errors)) { |
| 136 | - throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ". $errors, true); |
|
| 136 | + throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ".$errors, true); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Wait and retry once in case of a 502 Bad Gateway error |
| 140 | 140 | if ($statusCode === 502 && !($retry)) { |
| 141 | 141 | sleep(2); |
| 142 | - $this->_sendFirebase($deviceToken, $alert, $challenge, $projectId, $credentialsFile, $cacheTokens, $tokenCacheDir, true); |
|
| 142 | + $this->_sendFirebase($deviceToken, $alert, $challenge, $projectId, $credentialsFile, $cacheTokens, $tokenCacheDir, true); |
|
| 143 | 143 | return; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | // handle errors, ignoring registration_id's |
| 151 | 151 | $response = json_decode($result, true); |
| 152 | 152 | foreach ($response as $k => $v) { |
| 153 | - if ($k=="error") { |
|
| 153 | + if ($k == "error") { |
|
| 154 | 154 | throw new Tiqr_Message_Exception_SendFailure(sprintf("Error in FCM response: %s", $result), true); |
| 155 | 155 | } |
| 156 | 156 | } |