| @@ -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 | } | 
| @@ -49,7 +49,7 @@ discard block | ||
| 49 | 49 | /** | 
| 50 | 50 | * @throws Tiqr_Message_Exception_SendFailure | 
| 51 | 51 | */ | 
| 52 | - private function getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir ) | |
| 52 | + private function getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir) | |
| 53 | 53 |      { | 
| 54 | 54 | $client = new Google_Client(); | 
| 55 | 55 | // Try to add a file based cache for accesstokens, if configured | 
| @@ -60,8 +60,8 @@ discard block | ||
| 60 | 60 | $pool = new FilesystemCachePool($filesystem); | 
| 61 | 61 | |
| 62 | 62 | //set up a callback to log token refresh | 
| 63 | - $logger=$this->logger; | |
| 64 | -            $tokenCallback = function ($cacheKey, $accessToken) use ($logger) { | |
| 63 | + $logger = $this->logger; | |
| 64 | +            $tokenCallback = function($cacheKey, $accessToken) use ($logger) { | |
| 65 | 65 |                  $logger->info(sprintf('New access token received at cache key %s', $cacheKey)); | 
| 66 | 66 | }; | 
| 67 | 67 | $client->setTokenCallback($tokenCallback); | 
| @@ -93,9 +93,9 @@ discard block | ||
| 93 | 93 | * @param $retry boolean is this a 2nd attempt | 
| 94 | 94 | * @throws Tiqr_Message_Exception_SendFailure | 
| 95 | 95 | */ | 
| 96 | - private function _sendFirebase(string $deviceToken, string $alert, string $challenge, string $projectId, string $credentialsFile, bool $cacheTokens, string $tokenCacheDir, bool $retry=false) | |
| 96 | + private function _sendFirebase(string $deviceToken, string $alert, string $challenge, string $projectId, string $credentialsFile, bool $cacheTokens, string $tokenCacheDir, bool $retry = false) | |
| 97 | 97 |      { | 
| 98 | -        $apiurl = sprintf('https://fcm.googleapis.com/v1/projects/%s/messages:send',$projectId); | |
| 98 | +        $apiurl = sprintf('https://fcm.googleapis.com/v1/projects/%s/messages:send', $projectId); | |
| 99 | 99 | |
| 100 | 100 | $fields = [ | 
| 101 | 101 | 'message' => [ | 
| @@ -112,7 +112,7 @@ discard block | ||
| 112 | 112 | |
| 113 | 113 |          try { | 
| 114 | 114 | $headers = array( | 
| 115 | - 'Authorization: Bearer ' . $this->getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir), | |
| 115 | + 'Authorization: Bearer '.$this->getGoogleAccessToken($credentialsFile, $cacheTokens, $tokenCacheDir), | |
| 116 | 116 | 'Content-Type: application/json', | 
| 117 | 117 | ); | 
| 118 | 118 |          } catch (\Google\Exception $e) { | 
| @@ -136,13 +136,13 @@ discard block | ||
| 136 | 136 | } | 
| 137 | 137 | |
| 138 | 138 |          if (!empty($errors)) { | 
| 139 | -            throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ". $errors, true); | |
| 139 | +            throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ".$errors, true); | |
| 140 | 140 | } | 
| 141 | 141 | |
| 142 | 142 | // Wait and retry once in case of a 502 Bad Gateway error | 
| 143 | 143 |          if ($statusCode === 502 && !($retry)) { | 
| 144 | 144 | sleep(2); | 
| 145 | - $this->_sendFirebase($deviceToken, $alert, $challenge, $projectId, $credentialsFile, $cacheTokens, $tokenCacheDir, true); | |
| 145 | + $this->_sendFirebase($deviceToken, $alert, $challenge, $projectId, $credentialsFile, $cacheTokens, $tokenCacheDir, true); | |
| 146 | 146 | return; | 
| 147 | 147 | } | 
| 148 | 148 | |
| @@ -153,7 +153,7 @@ discard block | ||
| 153 | 153 | // handle errors, ignoring registration_id's | 
| 154 | 154 | $response = json_decode($result, true); | 
| 155 | 155 |          foreach ($response as $k => $v) { | 
| 156 | -            if ($k=="error") { | |
| 156 | +            if ($k == "error") { | |
| 157 | 157 |                  throw new Tiqr_Message_Exception_SendFailure(sprintf("Error in FCM response: %s", $result), true); | 
| 158 | 158 | } | 
| 159 | 159 | } |