@@ -552,17 +552,17 @@ discard block |
||
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | $metadata = array("service"=> |
| 555 | - array("displayName" => $this->_name, |
|
| 556 | - "identifier" => $this->_identifier, |
|
| 557 | - "logoUrl" => $this->_logoUrl, |
|
| 558 | - "infoUrl" => $this->_infoUrl, |
|
| 559 | - "authenticationUrl" => $authenticationUrl, |
|
| 560 | - "ocraSuite" => $this->_ocraSuite, |
|
| 561 | - "enrollmentUrl" => $enrollmentUrl |
|
| 562 | - ), |
|
| 563 | - "identity"=> |
|
| 564 | - array("identifier" =>$data["userId"], |
|
| 565 | - "displayName"=>$data["displayName"])); |
|
| 555 | + array("displayName" => $this->_name, |
|
| 556 | + "identifier" => $this->_identifier, |
|
| 557 | + "logoUrl" => $this->_logoUrl, |
|
| 558 | + "infoUrl" => $this->_infoUrl, |
|
| 559 | + "authenticationUrl" => $authenticationUrl, |
|
| 560 | + "ocraSuite" => $this->_ocraSuite, |
|
| 561 | + "enrollmentUrl" => $enrollmentUrl |
|
| 562 | + ), |
|
| 563 | + "identity"=> |
|
| 564 | + array("identifier" =>$data["userId"], |
|
| 565 | + "displayName"=>$data["displayName"])); |
|
| 566 | 566 | |
| 567 | 567 | $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
| 568 | 568 | |
@@ -585,18 +585,18 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | public function getEnrollmentSecret($enrollmentKey) |
| 587 | 587 | { |
| 588 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 589 | - $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
| 590 | - $enrollmentData = [ |
|
| 591 | - "userId" => $data["userId"], |
|
| 592 | - "sessionId" => $data["sessionId"] |
|
| 593 | - ]; |
|
| 594 | - $this->_stateStorage->setValue( |
|
| 595 | - self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 596 | - $enrollmentData, |
|
| 597 | - self::ENROLLMENT_EXPIRE |
|
| 598 | - ); |
|
| 599 | - return $secret; |
|
| 588 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 589 | + $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
| 590 | + $enrollmentData = [ |
|
| 591 | + "userId" => $data["userId"], |
|
| 592 | + "sessionId" => $data["sessionId"] |
|
| 593 | + ]; |
|
| 594 | + $this->_stateStorage->setValue( |
|
| 595 | + self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 596 | + $enrollmentData, |
|
| 597 | + self::ENROLLMENT_EXPIRE |
|
| 598 | + ); |
|
| 599 | + return $secret; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -635,18 +635,18 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | public function finalizeEnrollment($enrollmentSecret) |
| 637 | 637 | { |
| 638 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 639 | - if (is_array($data)) { |
|
| 640 | - // Enrollment is finalized, destroy our session data. |
|
| 641 | - $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
| 642 | - $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 643 | - } else { |
|
| 644 | - $this->logger->error( |
|
| 645 | - 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 646 | - 'Warning! the method will still return "true" as a result.' |
|
| 647 | - ); |
|
| 648 | - } |
|
| 649 | - return true; |
|
| 638 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 639 | + if (is_array($data)) { |
|
| 640 | + // Enrollment is finalized, destroy our session data. |
|
| 641 | + $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
| 642 | + $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 643 | + } else { |
|
| 644 | + $this->logger->error( |
|
| 645 | + 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 646 | + 'Warning! the method will still return "true" as a result.' |
|
| 647 | + ); |
|
| 648 | + } |
|
| 649 | + return true; |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | /** |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | $challengeUserId = NULL; |
| 685 | 685 | if (isset($state["userId"])) { |
| 686 | - $challengeUserId = $state["userId"]; |
|
| 686 | + $challengeUserId = $state["userId"]; |
|
| 687 | 687 | } |
| 688 | 688 | // Check if we're dealing with a second factor |
| 689 | 689 | if ($challengeUserId!=NULL && ($userId != $challengeUserId)) { |
@@ -830,6 +830,6 @@ discard block |
||
| 830 | 830 | */ |
| 831 | 831 | protected function _setEnrollmentStatus($sessionId, $status) |
| 832 | 832 | { |
| 833 | - $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
| 833 | + $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
| 834 | 834 | } |
| 835 | 835 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | /** |
| 75 | 75 | * Enrollment status codes |
| 76 | 76 | */ |
| 77 | - const ENROLLMENT_STATUS_IDLE = 1; // Nothing happens |
|
| 77 | + const ENROLLMENT_STATUS_IDLE = 1; // Nothing happens |
|
| 78 | 78 | const ENROLLMENT_STATUS_INITIALIZED = 2; // An enrollment session has begun |
| 79 | - const ENROLLMENT_STATUS_RETRIEVED = 3; // The device has retrieved the metadata |
|
| 80 | - const ENROLLMENT_STATUS_PROCESSED = 4; // The device has snet back a secret |
|
| 81 | - const ENROLLMENT_STATUS_FINALIZED = 5; // The application has stored the secret |
|
| 82 | - const ENROLLMENT_STATUS_VALIDATED = 6; // A first succesful authentication was performed |
|
| 79 | + const ENROLLMENT_STATUS_RETRIEVED = 3; // The device has retrieved the metadata |
|
| 80 | + const ENROLLMENT_STATUS_PROCESSED = 4; // The device has snet back a secret |
|
| 81 | + const ENROLLMENT_STATUS_FINALIZED = 5; // The application has stored the secret |
|
| 82 | + const ENROLLMENT_STATUS_VALIDATED = 6; // A first succesful authentication was performed |
|
| 83 | 83 | |
| 84 | 84 | const PREFIX_ENROLLMENT_SECRET = 'enrollsecret'; |
| 85 | 85 | const PREFIX_ENROLLMENT = 'enroll'; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param array $options |
| 163 | 163 | * @param int $version The protocol version to use (defaults to the latest) |
| 164 | 164 | */ |
| 165 | - public function __construct(LoggerInterface $logger, $options=array(), $version = 2) |
|
| 165 | + public function __construct(LoggerInterface $logger, $options = array(), $version = 2) |
|
| 166 | 166 | { |
| 167 | 167 | $this->_options = $options; |
| 168 | 168 | $this->logger = $logger; |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $this->logger->info(sprintf('Creating and sending a %s push notification', $notificationType)); |
| 307 | 307 | $message = new $class($this->_options); |
| 308 | 308 | $message->setId(time()); |
| 309 | - $message->setText("Please authenticate for " . $this->_name); |
|
| 309 | + $message->setText("Please authenticate for ".$this->_name); |
|
| 310 | 310 | $message->setAddress($notificationAddress); |
| 311 | 311 | $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey)); |
| 312 | 312 | $message->send(); |
@@ -375,13 +375,13 @@ discard block |
||
| 375 | 375 | * @param String $spIdentifier If SP and IDP are 2 different things, pass the url/identifier of the SP the user is logging into. |
| 376 | 376 | * For setups where IDP==SP, just leave this blank. |
| 377 | 377 | */ |
| 378 | - public function startAuthenticationSession($userId="", $sessionId="", $spIdentifier="") |
|
| 378 | + public function startAuthenticationSession($userId = "", $sessionId = "", $spIdentifier = "") |
|
| 379 | 379 | { |
| 380 | - if ($sessionId=="") { |
|
| 380 | + if ($sessionId == "") { |
|
| 381 | 381 | $sessionId = session_id(); |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if ($spIdentifier=="") { |
|
| 384 | + if ($spIdentifier == "") { |
|
| 385 | 385 | $spIdentifier = $this->_identifier; |
| 386 | 386 | } |
| 387 | 387 | |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier); |
| 393 | 393 | |
| 394 | - if ($userId!="") { |
|
| 394 | + if ($userId != "") { |
|
| 395 | 395 | $data["userId"] = $userId; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - $this->_stateStorage->setValue(self::PREFIX_CHALLENGE . $sessionKey, $data, self::CHALLENGE_EXPIRE); |
|
| 398 | + $this->_stateStorage->setValue(self::PREFIX_CHALLENGE.$sessionKey, $data, self::CHALLENGE_EXPIRE); |
|
| 399 | 399 | |
| 400 | 400 | return $sessionKey; |
| 401 | 401 | } |
@@ -415,9 +415,9 @@ discard block |
||
| 415 | 415 | * to php session) |
| 416 | 416 | * @return String The enrollment key |
| 417 | 417 | */ |
| 418 | - public function startEnrollmentSession($userId, $displayName, $sessionId="") |
|
| 418 | + public function startEnrollmentSession($userId, $displayName, $sessionId = "") |
|
| 419 | 419 | { |
| 420 | - if ($sessionId=="") { |
|
| 420 | + if ($sessionId == "") { |
|
| 421 | 421 | $sessionId = session_id(); |
| 422 | 422 | } |
| 423 | 423 | $enrollmentKey = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT); |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | "displayName" => $displayName, |
| 427 | 427 | "sessionId" => $sessionId |
| 428 | 428 | ]; |
| 429 | - $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT . $enrollmentKey, $data, self::ENROLLMENT_EXPIRE); |
|
| 429 | + $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT.$enrollmentKey, $data, self::ENROLLMENT_EXPIRE); |
|
| 430 | 430 | $this->_setEnrollmentStatus($sessionId, self::ENROLLMENT_STATUS_INITIALIZED); |
| 431 | 431 | |
| 432 | 432 | return $enrollmentKey; |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | * @param $sessionId The application's session identifier (defaults |
| 438 | 438 | * to php session) |
| 439 | 439 | */ |
| 440 | - public function resetEnrollmentSession($sessionId="") |
|
| 440 | + public function resetEnrollmentSession($sessionId = "") |
|
| 441 | 441 | { |
| 442 | - if ($sessionId=="") { |
|
| 442 | + if ($sessionId == "") { |
|
| 443 | 443 | $sessionId = session_id(); |
| 444 | 444 | } |
| 445 | 445 | |
@@ -484,9 +484,9 @@ discard block |
||
| 484 | 484 | * A first successful authentication was performed |
| 485 | 485 | * (todo: currently not used) |
| 486 | 486 | */ |
| 487 | - public function getEnrollmentStatus($sessionId="") |
|
| 487 | + public function getEnrollmentStatus($sessionId = "") |
|
| 488 | 488 | { |
| 489 | - if ($sessionId=="") { |
|
| 489 | + if ($sessionId == "") { |
|
| 490 | 490 | $sessionId = session_id(); |
| 491 | 491 | } |
| 492 | 492 | $status = $this->_stateStorage->getValue("enrollstatus".$sessionId); |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | public function getEnrollmentMetadata($enrollmentKey, $authenticationUrl, $enrollmentUrl) |
| 547 | 547 | { |
| 548 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 548 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 549 | 549 | if (!is_array($data)) { |
| 550 | 550 | $this->logger->error('Unable to find enrollment metadata in state storage'); |
| 551 | 551 | return false; |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | array("identifier" =>$data["userId"], |
| 565 | 565 | "displayName"=>$data["displayName"])); |
| 566 | 566 | |
| 567 | - $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 567 | + $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 568 | 568 | |
| 569 | 569 | $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_RETRIEVED); |
| 570 | 570 | return $metadata; |
@@ -585,14 +585,14 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | public function getEnrollmentSecret($enrollmentKey) |
| 587 | 587 | { |
| 588 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 588 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 589 | 589 | $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
| 590 | 590 | $enrollmentData = [ |
| 591 | 591 | "userId" => $data["userId"], |
| 592 | 592 | "sessionId" => $data["sessionId"] |
| 593 | 593 | ]; |
| 594 | 594 | $this->_stateStorage->setValue( |
| 595 | - self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 595 | + self::PREFIX_ENROLLMENT_SECRET.$secret, |
|
| 596 | 596 | $enrollmentData, |
| 597 | 597 | self::ENROLLMENT_EXPIRE |
| 598 | 598 | ); |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
| 643 | 643 | } else { |
| 644 | 644 | $this->logger->error( |
| 645 | - 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 645 | + 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. '. |
|
| 646 | 646 | 'Warning! the method will still return "true" as a result.' |
| 647 | 647 | ); |
| 648 | 648 | } |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | */ |
| 673 | 673 | public function authenticate($userId, $userSecret, $sessionKey, $response) |
| 674 | 674 | { |
| 675 | - $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 675 | + $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 676 | 676 | if (is_null($state)) { |
| 677 | 677 | $this->logger->info('The auth challenge could not be found in the state storage'); |
| 678 | 678 | return self::AUTH_RESULT_INVALID_CHALLENGE; |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | $challengeUserId = $state["userId"]; |
| 687 | 687 | } |
| 688 | 688 | // Check if we're dealing with a second factor |
| 689 | - if ($challengeUserId!=NULL && ($userId != $challengeUserId)) { |
|
| 689 | + if ($challengeUserId != NULL && ($userId != $challengeUserId)) { |
|
| 690 | 690 | $this->logger->error( |
| 691 | 691 | 'Authentication failed: the first factor user id does not match with that of the second factor' |
| 692 | 692 | ); |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | $this->_stateStorage->setValue("authenticated_".$sessionId, $userId, self::LOGIN_EXPIRE); |
| 705 | 705 | |
| 706 | 706 | // Clean up the challenge. |
| 707 | - $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 707 | + $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 708 | 708 | $this->logger->info('Authentication succeeded'); |
| 709 | 709 | return self::AUTH_RESULT_AUTHENTICATED; |
| 710 | 710 | } |
@@ -717,9 +717,9 @@ discard block |
||
| 717 | 717 | * @param String $sessionId The application's session identifier (defaults |
| 718 | 718 | * to the php session). |
| 719 | 719 | */ |
| 720 | - public function logout($sessionId="") |
|
| 720 | + public function logout($sessionId = "") |
|
| 721 | 721 | { |
| 722 | - if ($sessionId=="") { |
|
| 722 | + if ($sessionId == "") { |
|
| 723 | 723 | $sessionId = session_id(); |
| 724 | 724 | } |
| 725 | 725 | |
@@ -754,9 +754,9 @@ discard block |
||
| 754 | 754 | * @return mixed An array with user data if a user was logged in or NULL if |
| 755 | 755 | * no user is logged in. |
| 756 | 756 | */ |
| 757 | - public function getAuthenticatedUser($sessionId="") |
|
| 757 | + public function getAuthenticatedUser($sessionId = "") |
|
| 758 | 758 | { |
| 759 | - if ($sessionId=="") { |
|
| 759 | + if ($sessionId == "") { |
|
| 760 | 760 | $this->logger->debug('Using the PHP session id, as no session id was provided'); |
| 761 | 761 | $sessionId = session_id(); |
| 762 | 762 | } |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | */ |
| 776 | 776 | protected function _getChallengeUrl($sessionKey) |
| 777 | 777 | { |
| 778 | - $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 778 | + $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 779 | 779 | if (is_null($state)) { |
| 780 | 780 | $this->logger->error( |
| 781 | 781 | 'Unable find an existing challenge url in the state storage based on the existing session key' |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | return false; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - $userId = NULL; |
|
| 786 | + $userId = NULL; |
|
| 787 | 787 | $challenge = $state["challenge"]; |
| 788 | 788 | if (isset($state["userId"])) { |
| 789 | 789 | $userId = $state["userId"]; |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | $spIdentifier = $state["spIdentifier"]; |
| 792 | 792 | |
| 793 | 793 | // Last bit is the spIdentifier |
| 794 | - return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion; |
|
| 794 | + return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion; |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | protected function _uniqueSessionKey($prefix) |
| 816 | 816 | { |
| 817 | 817 | $value = 1; |
| 818 | - while ($value!=NULL) { |
|
| 818 | + while ($value != NULL) { |
|
| 819 | 819 | $sessionKey = $this->_ocraWrapper->generateSessionKey(); |
| 820 | 820 | $value = $this->_stateStorage->getValue($prefix.$sessionKey); |
| 821 | 821 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | if ($data === NULL) { |
| 33 | 33 | if ($failIfNotFound) { |
| 34 | - throw new Exception('Error loading data for user: ' . var_export($userId, TRUE)); |
|
| 34 | + throw new Exception('Error loading data for user: '.var_export($userId, TRUE)); |
|
| 35 | 35 | } else { |
| 36 | 36 | $this->logger->error('Error loading data for user from user storage (file storage)'); |
| 37 | 37 | return false; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function getPath() |
| 49 | 49 | { |
| 50 | - if (substr($this->path, -1)!="/") return $this->path."/"; |
|
| 50 | + if (substr($this->path, -1) != "/") return $this->path."/"; |
|
| 51 | 51 | return $this->path; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -47,7 +47,9 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | public function getPath() |
| 49 | 49 | { |
| 50 | - if (substr($this->path, -1)!="/") return $this->path."/"; |
|
| 50 | + if (substr($this->path, -1)!="/") { |
|
| 51 | + return $this->path."/"; |
|
| 52 | + } |
|
| 51 | 53 | return $this->path; |
| 52 | 54 | } |
| 53 | 55 | } |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | * @param LoggerInterface $logger |
| 46 | 46 | * @throws Exception An exception if an unknown storage is requested. |
| 47 | 47 | */ |
| 48 | - public static function getStorage($type="dummy", $options=array(), LoggerInterface $logger) |
|
| 48 | + public static function getStorage($type = "dummy", $options = array(), LoggerInterface $logger) |
|
| 49 | 49 | { |
| 50 | 50 | switch ($type) { |
| 51 | 51 | case "dummy": |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | * |
| 42 | 42 | * @throws Exception An exception if an unknown user storage is requested. |
| 43 | 43 | */ |
| 44 | - public static function getStorage($type="file", $options=array(), LoggerInterface $logger) |
|
| 44 | + public static function getStorage($type = "file", $options = array(), LoggerInterface $logger) |
|
| 45 | 45 | { |
| 46 | 46 | switch ($type) { |
| 47 | 47 | case "file": |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | * @return Tiqr_OcraService_Interface |
| 40 | 40 | * @throws Exception An exception if an unknown orca service type is requested. |
| 41 | 41 | */ |
| 42 | - public static function getOcraService($type="tiqr", $options=array(), LoggerInterface $logger) |
|
| 42 | + public static function getOcraService($type = "tiqr", $options = array(), LoggerInterface $logger) |
|
| 43 | 43 | { |
| 44 | 44 | switch ($type) { |
| 45 | 45 | case "tiqr": |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @throws RuntimeException When the options configuration array misses a required parameter |
| 48 | 48 | * |
| 49 | 49 | */ |
| 50 | - public static function getStorage($type="file", $options=array(), LoggerInterface $logger) |
|
| 50 | + public static function getStorage($type = "file", $options = array(), LoggerInterface $logger) |
|
| 51 | 51 | { |
| 52 | 52 | switch ($type) { |
| 53 | 53 | case "file": |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $pdoInstance = new PDO($options['dsn'],$options['username'],$options['password']); |
|
| 78 | + $pdoInstance = new PDO($options['dsn'], $options['username'], $options['password']); |
|
| 79 | 79 | // Set a hard-coded default for the probability the expired state is removed |
| 80 | 80 | // 0.1 translates to a 10% chance the garbage collection is executed |
| 81 | 81 | $cleanupProbability = 0.1; |
@@ -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 | } |
@@ -51,8 +51,8 @@ |
||
| 51 | 51 | public function setValue($key, $value, $expire=0) |
| 52 | 52 | { |
| 53 | 53 | $envelope = array("expire"=>$expire, |
| 54 | - "createdAt"=>time(), |
|
| 55 | - "value"=>$value); |
|
| 54 | + "createdAt"=>time(), |
|
| 55 | + "value"=>$value); |
|
| 56 | 56 | $filename = $this->getFilenameByKey($key); |
| 57 | 57 | |
| 58 | 58 | if (!file_put_contents($filename, serialize($envelope))) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $this->path = $path; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function setValue($key, $value, $expire=0) |
|
| 47 | + public function setValue($key, $value, $expire = 0) |
|
| 48 | 48 | { |
| 49 | 49 | $envelope = array("expire"=>$expire, |
| 50 | 50 | "createdAt"=>time(), |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | private function getPath(): string |
| 100 | 100 | { |
| 101 | - if (substr($this->path, -1)!=="/") { |
|
| 102 | - return $this->path . "/"; |
|
| 101 | + if (substr($this->path, -1) !== "/") { |
|
| 102 | + return $this->path."/"; |
|
| 103 | 103 | } |
| 104 | 104 | return $this->path; |
| 105 | 105 | } |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | * a state storage instance of a certain type. |
| 61 | 61 | * @param array $options An array of options for the state storage |
| 62 | 62 | */ |
| 63 | - public function __construct($options=array(), LoggerInterface $logger) |
|
| 63 | + public function __construct($options = array(), LoggerInterface $logger) |
|
| 64 | 64 | { |
| 65 | 65 | $this->logger = $logger; |
| 66 | 66 | $this->_options = $options; |