diff --git a/src/Service/GlobalAuthenticationService.php b/src/Service/GlobalAuthenticationService.php index 034b75a..ff11fed 100644 --- a/src/Service/GlobalAuthenticationService.php +++ b/src/Service/GlobalAuthenticationService.php @@ -3,10 +3,10 @@ namespace ID3Global\Service; use Exception; -use LogicException; use ID3Global\Exceptions\IdentityVerificationFailureException; use ID3Global\Gateway\GlobalAuthenticationGateway; use ID3Global\Identity\Identity; +use LogicException; use SoapClient; use stdClass; @@ -18,27 +18,29 @@ class GlobalAuthenticationService extends ID3BaseService private GlobalAuthenticationGateway $gateway; /** - * @var string The Profile ID to be used when verifying identities via $this->verifyIdentity(). + * @var string The Profile ID to be used when verifying identities via->verifyIdentity(). + * * @see self::setProfileId() */ private string $profileId = ''; /** - * @var int The version of the Profile ID to be used when verifying identities via $this->verifyIdentity(). - * The special value of 0 is treated specially by ID3global and represents the 'most recent version of the profile'. + * @var int The version of the Profile ID to be used when verifying identities via->verifyIdentity(). + * The special value of 0 is treated specially by ID3global and represents the 'most recent version of the profile'. + * * @see self::setProfileVersion() */ private int $profileVersion = 0; /** * @var Identity The most recent Identity object to be verified by the ID3global API (regardless of the outcome of - * the API request). + * the API request). */ private Identity $lastIdentity; /** * @var string|null The most recent customer reference to be verified by the ID3global API (regardless of the - * outcome of the API request). + * outcome of the API request). */ private ?string $lastCustomerReference; @@ -85,12 +87,13 @@ public function __construct(GlobalAuthenticationGateway $gateway, array $soapOpt * necessary for compliance purposes. * * @throws IdentityVerificationFailureException Thrown specifically if the SOAP response was 'valid' according to - * SOAP but does not conform to the expected response (missing BandText or Score elements of the response). - * @throws Exception May throw a generic Exception or SoapFault if any part of the SOAP callstack fails. + * SOAP but does not conform to the expected response (missing BandText or Score elements of the response). + * @throws Exception May throw a generic Exception or SoapFault if any part of the SOAP callstack fails. * * @return string The raw BandText as provided by the API. */ - public function verifyIdentity(Identity $identity, ?string $customerReference = null): string { + public function verifyIdentity(Identity $identity, ?string $customerReference = null): string + { $this->lastIdentity = $identity; $this->lastCustomerReference = $customerReference; @@ -98,6 +101,7 @@ public function verifyIdentity(Identity $identity, ?string $customerReference = if (!$this->profileId) { $error = 'An ID3global Profile ID must be set by calling setProfileId() before calling verifyIdentity().'; + throw new LogicException($error); } @@ -158,7 +162,7 @@ public function getProfileVersion(): int /** * @return Identity|null The last Identity object to be verified by the API (regardless of whether it was - * successfully accepted by the ID3global API or not). Returns null if ->verifyIdentity() has not yet been called. + * successfully accepted by the ID3global API or not). Returns null if ->verifyIdentity() has not yet been called. */ public function getLastVerifiedIdentity(): ?Identity { @@ -167,7 +171,7 @@ public function getLastVerifiedIdentity(): ?Identity /** * @return string|null The last customer reference value to be verified by the API (regardless of whether it was - * successfully accepted by the ID3global API or not). Returns null if ->verifyIdentity() has not yet been called. + * successfully accepted by the ID3global API or not). Returns null if ->verifyIdentity() has not yet been called. */ public function getLastCustomerReference(): ?string { @@ -176,8 +180,8 @@ public function getLastCustomerReference(): ?string /** * @return stdClass|null Either the full response as returned by ID3global, or null if no call has been made yet. If - * the request was made but failed to validate (e.g. the ID3global API returned an invalid SOAP object, this will - * still be populated. + * the request was made but failed to validate (e.g. the ID3global API returned an invalid SOAP object, this will + * still be populated. */ public function getLastVerifyIdentityResponse(): ?stdClass { diff --git a/tests/Service/GlobalAuthenticationServiceTest.php b/tests/Service/GlobalAuthenticationServiceTest.php index 32fedf4..73daf5c 100644 --- a/tests/Service/GlobalAuthenticationServiceTest.php +++ b/tests/Service/GlobalAuthenticationServiceTest.php @@ -4,11 +4,11 @@ use DateTime; use ID3Global\Exceptions\IdentityVerificationFailureException; -use LogicException; use ID3Global\Identity\Identity; use ID3Global\Identity\PersonalDetails; use ID3Global\Service\GlobalAuthenticationService; use ID3Global\Stubs\Gateway\GlobalAuthenticationGatewayFake; +use LogicException; use PHPUnit\Framework\TestCase; class GlobalAuthenticationServiceTest extends TestCase @@ -27,7 +27,7 @@ public function setUp(): void /** * @dataProvider authenticateSp * - * @param string|null $customerReference + * @param string|null $customerReference * @param DateTime|null $birthday * * @throws IdentityVerificationFailureException