@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function setBaseURL($apiBaseURL) |
| 27 | 27 | { |
| 28 | - $this->_apiBaseURL = rtrim($apiBaseURL, '/') . '/'; |
|
| 28 | + $this->_apiBaseURL = rtrim($apiBaseURL, '/').'/'; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | protected function callAPI($resource, $method = "GET", $data = array(), $headers = array()) |
| 79 | 79 | { |
| 80 | 80 | $ch = curl_init(); |
| 81 | - curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL . ltrim($resource, '/')); |
|
| 81 | + curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL.ltrim($resource, '/')); |
|
| 82 | 82 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 83 | 83 | |
| 84 | 84 | // Explicitly empty null values, because http_build_query will throw away |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $headerArray = array(); |
| 109 | 109 | foreach ($headers as $key => $value) { |
| 110 | - $headerArray[] = $key . ': ' . $value; |
|
| 110 | + $headerArray[] = $key.': '.$value; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray); |
@@ -453,7 +453,9 @@ |
||
| 453 | 453 | $sessionId = session_id(); |
| 454 | 454 | } |
| 455 | 455 | $status = $this->_stateStorage->getValue("enrollstatus".$sessionId); |
| 456 | - if (is_null($status)) return self::ENROLLMENT_STATUS_IDLE; |
|
| 456 | + if (is_null($status)) { |
|
| 457 | + return self::ENROLLMENT_STATUS_IDLE; |
|
| 458 | + } |
|
| 457 | 459 | return $status; |
| 458 | 460 | } |
| 459 | 461 | |
@@ -584,17 +584,17 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | $metadata = array("service"=> |
| 587 | - array("displayName" => $this->_name, |
|
| 588 | - "identifier" => $this->_identifier, |
|
| 589 | - "logoUrl" => $this->_logoUrl, |
|
| 590 | - "infoUrl" => $this->_infoUrl, |
|
| 591 | - "authenticationUrl" => $authenticationUrl, |
|
| 592 | - "ocraSuite" => $this->_ocraSuite, |
|
| 593 | - "enrollmentUrl" => $enrollmentUrl |
|
| 594 | - ), |
|
| 595 | - "identity"=> |
|
| 596 | - array("identifier" =>$data["userId"], |
|
| 597 | - "displayName"=>$data["displayName"])); |
|
| 587 | + array("displayName" => $this->_name, |
|
| 588 | + "identifier" => $this->_identifier, |
|
| 589 | + "logoUrl" => $this->_logoUrl, |
|
| 590 | + "infoUrl" => $this->_infoUrl, |
|
| 591 | + "authenticationUrl" => $authenticationUrl, |
|
| 592 | + "ocraSuite" => $this->_ocraSuite, |
|
| 593 | + "enrollmentUrl" => $enrollmentUrl |
|
| 594 | + ), |
|
| 595 | + "identity"=> |
|
| 596 | + array("identifier" =>$data["userId"], |
|
| 597 | + "displayName"=>$data["displayName"])); |
|
| 598 | 598 | |
| 599 | 599 | $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
| 600 | 600 | |
@@ -618,18 +618,18 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | public function getEnrollmentSecret(string $enrollmentKey): string |
| 620 | 620 | { |
| 621 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 622 | - $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
| 623 | - $enrollmentData = [ |
|
| 624 | - "userId" => $data["userId"], |
|
| 625 | - "sessionId" => $data["sessionId"] |
|
| 626 | - ]; |
|
| 627 | - $this->_stateStorage->setValue( |
|
| 628 | - self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 629 | - $enrollmentData, |
|
| 630 | - self::ENROLLMENT_EXPIRE |
|
| 631 | - ); |
|
| 632 | - return $secret; |
|
| 621 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 622 | + $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
| 623 | + $enrollmentData = [ |
|
| 624 | + "userId" => $data["userId"], |
|
| 625 | + "sessionId" => $data["sessionId"] |
|
| 626 | + ]; |
|
| 627 | + $this->_stateStorage->setValue( |
|
| 628 | + self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 629 | + $enrollmentData, |
|
| 630 | + self::ENROLLMENT_EXPIRE |
|
| 631 | + ); |
|
| 632 | + return $secret; |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -668,18 +668,18 @@ discard block |
||
| 668 | 668 | */ |
| 669 | 669 | public function finalizeEnrollment($enrollmentSecret) |
| 670 | 670 | { |
| 671 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 672 | - if (is_array($data)) { |
|
| 673 | - // Enrollment is finalized, destroy our session data. |
|
| 674 | - $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
| 675 | - $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 676 | - } else { |
|
| 677 | - $this->logger->error( |
|
| 678 | - 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 679 | - 'Warning! the method will still return "true" as a result.' |
|
| 680 | - ); |
|
| 681 | - } |
|
| 682 | - return true; |
|
| 671 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 672 | + if (is_array($data)) { |
|
| 673 | + // Enrollment is finalized, destroy our session data. |
|
| 674 | + $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
| 675 | + $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 676 | + } else { |
|
| 677 | + $this->logger->error( |
|
| 678 | + 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 679 | + 'Warning! the method will still return "true" as a result.' |
|
| 680 | + ); |
|
| 681 | + } |
|
| 682 | + return true; |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | $challengeUserId = NULL; |
| 718 | 718 | if (isset($state["userId"])) { |
| 719 | - $challengeUserId = $state["userId"]; |
|
| 719 | + $challengeUserId = $state["userId"]; |
|
| 720 | 720 | } |
| 721 | 721 | // Check if we're dealing with a second factor |
| 722 | 722 | if ($challengeUserId!=NULL && ($userId != $challengeUserId)) { |
@@ -864,6 +864,6 @@ discard block |
||
| 864 | 864 | */ |
| 865 | 865 | protected function _setEnrollmentStatus($sessionId, $status) |
| 866 | 866 | { |
| 867 | - $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
| 867 | + $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
| 868 | 868 | } |
| 869 | 869 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param array $options |
| 194 | 194 | * @param int $version The protocol version to use (defaults to the latest) |
| 195 | 195 | */ |
| 196 | - public function __construct(LoggerInterface $logger, $options=array(), $version = 2) |
|
| 196 | + public function __construct(LoggerInterface $logger, $options = array(), $version = 2) |
|
| 197 | 197 | { |
| 198 | 198 | $this->_options = $options; |
| 199 | 199 | $this->logger = $logger; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $this->logger->info(sprintf('Creating and sending a %s push notification', $notificationType)); |
| 348 | 348 | $message->setId(time()); |
| 349 | - $message->setText("Please authenticate for " . $this->_name); |
|
| 349 | + $message->setText("Please authenticate for ".$this->_name); |
|
| 350 | 350 | $message->setAddress($notificationAddress); |
| 351 | 351 | $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey)); |
| 352 | 352 | $message->send(); |
@@ -417,13 +417,13 @@ discard block |
||
| 417 | 417 | * @return Session key |
| 418 | 418 | * @throws Exception |
| 419 | 419 | */ |
| 420 | - public function startAuthenticationSession(string $userId="", string $sessionId="", string $spIdentifier=""): string |
|
| 420 | + public function startAuthenticationSession(string $userId = "", string $sessionId = "", string $spIdentifier = ""): string |
|
| 421 | 421 | { |
| 422 | - if ($sessionId=="") { |
|
| 422 | + if ($sessionId == "") { |
|
| 423 | 423 | $sessionId = session_id(); |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if ($spIdentifier=="") { |
|
| 426 | + if ($spIdentifier == "") { |
|
| 427 | 427 | $spIdentifier = $this->_identifier; |
| 428 | 428 | } |
| 429 | 429 | |
@@ -433,11 +433,11 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier); |
| 435 | 435 | |
| 436 | - if ($userId!="") { |
|
| 436 | + if ($userId != "") { |
|
| 437 | 437 | $data["userId"] = $userId; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - $this->_stateStorage->setValue(self::PREFIX_CHALLENGE . $sessionKey, $data, self::CHALLENGE_EXPIRE); |
|
| 440 | + $this->_stateStorage->setValue(self::PREFIX_CHALLENGE.$sessionKey, $data, self::CHALLENGE_EXPIRE); |
|
| 441 | 441 | |
| 442 | 442 | return $sessionKey; |
| 443 | 443 | } |
@@ -457,9 +457,9 @@ discard block |
||
| 457 | 457 | * to php session) |
| 458 | 458 | * @return String The enrollment key |
| 459 | 459 | */ |
| 460 | - public function startEnrollmentSession(string $userId, string $displayName, string $sessionId="") |
|
| 460 | + public function startEnrollmentSession(string $userId, string $displayName, string $sessionId = "") |
|
| 461 | 461 | { |
| 462 | - if ($sessionId=="") { |
|
| 462 | + if ($sessionId == "") { |
|
| 463 | 463 | $sessionId = session_id(); |
| 464 | 464 | } |
| 465 | 465 | $enrollmentKey = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT); |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | "displayName" => $displayName, |
| 469 | 469 | "sessionId" => $sessionId |
| 470 | 470 | ]; |
| 471 | - $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT . $enrollmentKey, $data, self::ENROLLMENT_EXPIRE); |
|
| 471 | + $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT.$enrollmentKey, $data, self::ENROLLMENT_EXPIRE); |
|
| 472 | 472 | $this->_setEnrollmentStatus($sessionId, self::ENROLLMENT_STATUS_INITIALIZED); |
| 473 | 473 | |
| 474 | 474 | return $enrollmentKey; |
@@ -479,9 +479,9 @@ discard block |
||
| 479 | 479 | * @param $sessionId The application's session identifier (defaults |
| 480 | 480 | * to php session) |
| 481 | 481 | */ |
| 482 | - public function resetEnrollmentSession($sessionId="") |
|
| 482 | + public function resetEnrollmentSession($sessionId = "") |
|
| 483 | 483 | { |
| 484 | - if ($sessionId=="") { |
|
| 484 | + if ($sessionId == "") { |
|
| 485 | 485 | $sessionId = session_id(); |
| 486 | 486 | } |
| 487 | 487 | |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | * |
| 516 | 516 | * Does not throw |
| 517 | 517 | */ |
| 518 | - public function getEnrollmentStatus(string $sessionId=""): int |
|
| 518 | + public function getEnrollmentStatus(string $sessionId = ""): int |
|
| 519 | 519 | { |
| 520 | - if ($sessionId=="") { |
|
| 520 | + if ($sessionId == "") { |
|
| 521 | 521 | $sessionId = session_id(); |
| 522 | 522 | } |
| 523 | 523 | $status = $this->_stateStorage->getValue("enrollstatus".$sessionId); |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | */ |
| 578 | 578 | public function getEnrollmentMetadata($enrollmentKey, $authenticationUrl, $enrollmentUrl): array |
| 579 | 579 | { |
| 580 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 580 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 581 | 581 | if (!is_array($data)) { |
| 582 | 582 | $this->logger->error('Unable to find enrollment metadata in state storage'); |
| 583 | 583 | throw new Exception('Unable to find enrollment metadata in state storage'); |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | array("identifier" =>$data["userId"], |
| 597 | 597 | "displayName"=>$data["displayName"])); |
| 598 | 598 | |
| 599 | - $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 599 | + $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 600 | 600 | |
| 601 | 601 | $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_RETRIEVED); |
| 602 | 602 | return $metadata; |
@@ -618,14 +618,14 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | public function getEnrollmentSecret(string $enrollmentKey): string |
| 620 | 620 | { |
| 621 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 621 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 622 | 622 | $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
| 623 | 623 | $enrollmentData = [ |
| 624 | 624 | "userId" => $data["userId"], |
| 625 | 625 | "sessionId" => $data["sessionId"] |
| 626 | 626 | ]; |
| 627 | 627 | $this->_stateStorage->setValue( |
| 628 | - self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 628 | + self::PREFIX_ENROLLMENT_SECRET.$secret, |
|
| 629 | 629 | $enrollmentData, |
| 630 | 630 | self::ENROLLMENT_EXPIRE |
| 631 | 631 | ); |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
| 676 | 676 | } else { |
| 677 | 677 | $this->logger->error( |
| 678 | - 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 678 | + 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. '. |
|
| 679 | 679 | 'Warning! the method will still return "true" as a result.' |
| 680 | 680 | ); |
| 681 | 681 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | */ |
| 706 | 706 | public function authenticate($userId, $userSecret, $sessionKey, $response) |
| 707 | 707 | { |
| 708 | - $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 708 | + $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 709 | 709 | if (is_null($state)) { |
| 710 | 710 | $this->logger->info('The auth challenge could not be found in the state storage'); |
| 711 | 711 | return self::AUTH_RESULT_INVALID_CHALLENGE; |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | $challengeUserId = $state["userId"]; |
| 720 | 720 | } |
| 721 | 721 | // Check if we're dealing with a second factor |
| 722 | - if ($challengeUserId!=NULL && ($userId != $challengeUserId)) { |
|
| 722 | + if ($challengeUserId != NULL && ($userId != $challengeUserId)) { |
|
| 723 | 723 | $this->logger->error( |
| 724 | 724 | 'Authentication failed: the first factor user id does not match with that of the second factor' |
| 725 | 725 | ); |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | $this->_stateStorage->setValue("authenticated_".$sessionId, $userId, self::LOGIN_EXPIRE); |
| 738 | 738 | |
| 739 | 739 | // Clean up the challenge. |
| 740 | - $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 740 | + $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 741 | 741 | $this->logger->info('Authentication succeeded'); |
| 742 | 742 | return self::AUTH_RESULT_AUTHENTICATED; |
| 743 | 743 | } |
@@ -750,9 +750,9 @@ discard block |
||
| 750 | 750 | * @param String $sessionId The application's session identifier (defaults |
| 751 | 751 | * to the php session). |
| 752 | 752 | */ |
| 753 | - public function logout($sessionId="") |
|
| 753 | + public function logout($sessionId = "") |
|
| 754 | 754 | { |
| 755 | - if ($sessionId=="") { |
|
| 755 | + if ($sessionId == "") { |
|
| 756 | 756 | $sessionId = session_id(); |
| 757 | 757 | } |
| 758 | 758 | |
@@ -791,9 +791,9 @@ discard block |
||
| 791 | 791 | * |
| 792 | 792 | * Does not throw |
| 793 | 793 | */ |
| 794 | - public function getAuthenticatedUser($sessionId="") |
|
| 794 | + public function getAuthenticatedUser($sessionId = "") |
|
| 795 | 795 | { |
| 796 | - if ($sessionId=="") { |
|
| 796 | + if ($sessionId == "") { |
|
| 797 | 797 | $this->logger->debug('Using the PHP session id, as no session id was provided'); |
| 798 | 798 | $sessionId = session_id(); |
| 799 | 799 | } |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | */ |
| 812 | 812 | protected function _getChallengeUrl($sessionKey): string |
| 813 | 813 | { |
| 814 | - $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 814 | + $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 815 | 815 | if (is_null($state)) { |
| 816 | 816 | $this->logger->error( |
| 817 | 817 | sprintf( |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | throw new Exception('Cannot find sessionkey'); |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - $userId = NULL; |
|
| 825 | + $userId = NULL; |
|
| 826 | 826 | $challenge = $state["challenge"]; |
| 827 | 827 | if (isset($state["userId"])) { |
| 828 | 828 | $userId = $state["userId"]; |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | $spIdentifier = $state["spIdentifier"]; |
| 831 | 831 | |
| 832 | 832 | // Last bit is the spIdentifier |
| 833 | - return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion; |
|
| 833 | + return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /** |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | protected function _uniqueSessionKey(): string |
| 853 | 853 | { |
| 854 | 854 | |
| 855 | - return bin2hex( Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES) ); |
|
| 855 | + return bin2hex(Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES)); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * @param boolean $temporary temporary failure? |
| 36 | 36 | * @param Exception $parent parent exception |
| 37 | 37 | */ |
| 38 | - public function __construct($message, $temporary=false, Exception $parent=null) |
|
| 38 | + public function __construct($message, $temporary = false, Exception $parent = null) |
|
| 39 | 39 | { |
| 40 | 40 | parent::__construct($message, $parent); |
| 41 | 41 | $this->_temporary = $temporary; |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | * @param string $message exception message |
| 30 | 30 | * @param Exception $parent parent exception |
| 31 | 31 | */ |
| 32 | - public function __construct($message, $parent=null) |
|
| 33 | - { |
|
| 34 | - parent::__construct($message, 0, $parent); |
|
| 35 | - } |
|
| 32 | + public function __construct($message, $parent=null) |
|
| 33 | + { |
|
| 34 | + parent::__construct($message, 0, $parent); |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * @param string $message exception message |
| 30 | 30 | * @param Exception $parent parent exception |
| 31 | 31 | */ |
| 32 | - public function __construct($message, $parent=null) |
|
| 32 | + public function __construct($message, $parent = null) |
|
| 33 | 33 | { |
| 34 | 34 | parent::__construct($message, 0, $parent); |
| 35 | 35 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * @param boolean $temporary temporary failure? |
| 36 | 36 | * @param Exception $parent parent exception |
| 37 | 37 | */ |
| 38 | - public function __construct($message, $temporary=false, Exception $parent=null) |
|
| 38 | + public function __construct($message, $temporary = false, Exception $parent = null) |
|
| 39 | 39 | { |
| 40 | 40 | parent::__construct($message, $parent); |
| 41 | 41 | $this->_temporary = $temporary; |
@@ -97,9 +97,9 @@ |
||
| 97 | 97 | |
| 98 | 98 | // Wait and retry once in case of a 502 Bad Gateway error |
| 99 | 99 | if ($statusCode === 502 && !($retry)) { |
| 100 | - sleep(2); |
|
| 101 | - $this->_sendFirebase($deviceToken, $alert, $challenge, $apiKey, true); |
|
| 102 | - return; |
|
| 100 | + sleep(2); |
|
| 101 | + $this->_sendFirebase($deviceToken, $alert, $challenge, $apiKey, true); |
|
| 102 | + return; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | if ($statusCode !== 200) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @throws Tiqr_Message_Exception_SendFailure |
| 59 | 59 | */ |
| 60 | - private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry=false) |
|
| 60 | + private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry = false) |
|
| 61 | 61 | { |
| 62 | 62 | $msg = array( |
| 63 | 63 | 'challenge' => $challenge, |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | 73 | $headers = array( |
| 74 | - 'Authorization: key=' . $apiKey, |
|
| 74 | + 'Authorization: key='.$apiKey, |
|
| 75 | 75 | 'Content-Type: application/json', |
| 76 | 76 | ); |
| 77 | 77 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $result = curl_exec($ch); |
| 85 | 85 | $errors = curl_error($ch); |
| 86 | 86 | $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 87 | - $remoteip = curl_getinfo($ch,CURLINFO_PRIMARY_IP); |
|
| 87 | + $remoteip = curl_getinfo($ch, CURLINFO_PRIMARY_IP); |
|
| 88 | 88 | curl_close($ch); |
| 89 | 89 | |
| 90 | 90 | if ($result === false) { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | if (!empty($errors)) { |
| 95 | - throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ". $errors, true); |
|
| 95 | + throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ".$errors, true); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Wait and retry once in case of a 502 Bad Gateway error |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $response = json_decode($result, true); |
| 111 | 111 | foreach ($response['results'] as $k => $v) { |
| 112 | 112 | if (isset($v['error'])) { |
| 113 | - throw new Tiqr_Message_Exception_SendFailure("Error in FCM response: " . $v['error'], true); |
|
| 113 | + throw new Tiqr_Message_Exception_SendFailure("Error in FCM response: ".$v['error'], true); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | public static function randomBytes($length) |
| 40 | 40 | { |
| 41 | 41 | // Get $length cryptographically secure pseudo-random bytes |
| 42 | - $rnd=\random_bytes($length); |
|
| 42 | + $rnd = \random_bytes($length); |
|
| 43 | 43 | |
| 44 | 44 | if (strlen($rnd) !== $length) { |
| 45 | 45 | throw new Exception("random_bytes did not return the requested number of bytes"); |
@@ -41,15 +41,15 @@ |
||
| 41 | 41 | { |
| 42 | 42 | $url = $this->_options["url"]."?appId=".$this->_options["appid"]; |
| 43 | 43 | |
| 44 | - $url.= "¬ificationToken=".$notificationToken; |
|
| 44 | + $url .= "¬ificationToken=".$notificationToken; |
|
| 45 | 45 | |
| 46 | 46 | $output = file_get_contents($url); |
| 47 | - if (stripos($output, "not found")!==false) { |
|
| 47 | + if (stripos($output, "not found") !== false) { |
|
| 48 | 48 | $this->logger->error('Token Exchange failed and responded with: not found', ['full output' => $output]); |
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if (stripos($output, "error")!==false) { |
|
| 52 | + if (stripos($output, "error") !== false) { |
|
| 53 | 53 | $this->logger->error('Token Exchange failed and responded with: error', ['full output' => $output]); |
| 54 | 54 | return false; |
| 55 | 55 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | public function encrypt($data); |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Decrypts the given data. |
|
| 44 | + * Decrypts the given data. |
|
| 45 | 45 | * |
| 46 | 46 | * @param String $data Data to decrypt. |
| 47 | 47 | * |