From 7b32adeecef80596bbdc7b9d43c5361eb9a2b71d Mon Sep 17 00:00:00 2001 From: Lowenna Baggaley Date: Wed, 15 Nov 2023 08:21:17 +0000 Subject: [PATCH] phpcbf app/src/App/DataAccess --- service-api/app/features/bootstrap/app.php | 7 +- .../app/features/bootstrap/config.pact.php | 19 +- service-api/app/features/bootstrap/config.php | 61 ++-- .../bootstrap/container.acceptance.php | 2 +- .../context/Acceptance/CommonContext.php | 4 + .../context/Acceptance/FeatureFlagContext.php | 2 +- .../context/Acceptance/LpaContext.php | 8 +- .../context/BaseAcceptanceContextTrait.php | 4 +- .../context/Integration/AccountContext.php | 270 +++++++++--------- .../Integration/BaseIntegrationContext.php | 6 +- .../Integration/FeatureFlagContext.php | 4 +- .../context/Integration/LpaContext.php | 36 +-- .../features/context/UsesPactContextTrait.php | 6 +- .../src/DataAccess/ApiGateway/ActorCodes.php | 35 +-- .../ApiGateway/ActorCodesFactory.php | 3 +- .../App/src/DataAccess/ApiGateway/Lpas.php | 43 +-- .../src/DataAccess/ApiGateway/LpasFactory.php | 3 +- .../DataAccess/ApiGateway/RequestSigner.php | 8 +- .../src/DataAccess/DynamoDb/ActorCodes.php | 29 +- .../DataAccess/DynamoDb/ActorCodesFactory.php | 3 +- .../DataAccess/DynamoDb/ActorUsersFactory.php | 3 +- .../DataAccess/DynamoDb/UserLpaActorMap.php | 2 +- .../DynamoDb/ViewerCodeActivity.php | 37 +-- .../DynamoDb/ViewerCodeActivityFactory.php | 3 +- .../src/DataAccess/DynamoDb/ViewerCodes.php | 68 ++--- .../DynamoDb/ViewerCodesFactory.php | 3 +- .../Repository/ActorUsersInterface.php | 1 - .../Repository/KeyCollisionException.php | 5 +- .../Repository/Response/ActorCode.php | 9 +- .../DataAccess/Repository/Response/Lpa.php | 9 +- .../ViewerCodeActivityInterface.php | 1 - .../Repository/ViewerCodesInterface.php | 7 +- 32 files changed, 307 insertions(+), 394 deletions(-) diff --git a/service-api/app/features/bootstrap/app.php b/service-api/app/features/bootstrap/app.php index b5cb54b49f..96f197ff34 100644 --- a/service-api/app/features/bootstrap/app.php +++ b/service-api/app/features/bootstrap/app.php @@ -2,12 +2,9 @@ declare(strict_types=1); -use Mezzio\Application; -use Mezzio\MiddlewareFactory; - /** @var \Mezzio\Application $app */ -$app = $container->get(Application::class); -$factory = $container->get(MiddlewareFactory::class); +$app = $container->get(\Mezzio\Application::class); +$factory = $container->get(\Mezzio\MiddlewareFactory::class); // Execute programmatic/declarative middleware pipeline and routing // configuration statements diff --git a/service-api/app/features/bootstrap/config.pact.php b/service-api/app/features/bootstrap/config.pact.php index 4f663c3e34..0eadbdcffa 100644 --- a/service-api/app/features/bootstrap/config.pact.php +++ b/service-api/app/features/bootstrap/config.pact.php @@ -2,22 +2,15 @@ declare(strict_types=1); -use App\DataAccess\ApiGateway\ActorCodes; -use BehatTest\DataAccess\ApiGateway\PactActorCodesFactory; -use App\DataAccess\ApiGateway\InstructionsAndPreferencesImages; -use BehatTest\DataAccess\ApiGateway\PactInstructionsAndPreferencesImagesFactory; -use App\DataAccess\ApiGateway\Lpas; -use BehatTest\DataAccess\ApiGateway\PactLpasFactory; - return [ 'dependencies' => [ 'factories' => [ - ActorCodes::class - => PactActorCodesFactory::class, - InstructionsAndPreferencesImages::class - => PactInstructionsAndPreferencesImagesFactory::class, - Lpas::class - => PactLpasFactory::class, + App\DataAccess\ApiGateway\ActorCodes::class + => BehatTest\DataAccess\ApiGateway\PactActorCodesFactory::class, + App\DataAccess\ApiGateway\InstructionsAndPreferencesImages::class + => BehatTest\DataAccess\ApiGateway\PactInstructionsAndPreferencesImagesFactory::class, + App\DataAccess\ApiGateway\Lpas::class + => BehatTest\DataAccess\ApiGateway\PactLpasFactory::class, ], ], ]; diff --git a/service-api/app/features/bootstrap/config.php b/service-api/app/features/bootstrap/config.php index 2823c67f17..424f50cf55 100644 --- a/service-api/app/features/bootstrap/config.php +++ b/service-api/app/features/bootstrap/config.php @@ -3,33 +3,33 @@ declare(strict_types=1); use Laminas\ConfigAggregator\ConfigAggregator; -use Http\Adapter\Guzzle6\Client; -use BehatTest\Http\Adapter\Guzzle6\TestClientFactory; -use Aws\Sdk; -use BehatTest\Common\Service\Aws\SdkFactory; -use App\Service\Log\RequestTracingLogProcessorFactory; return [ - 'debug' => true, + 'debug' => true, ConfigAggregator::ENABLE_CACHE => false, - 'dependencies' => [ + + 'dependencies' => [ 'factories' => [ - Client::class => TestClientFactory::class, + Http\Adapter\Guzzle6\Client::class => BehatTest\Http\Adapter\Guzzle6\TestClientFactory::class, GuzzleHttp\Client::class => BehatTest\GuzzleHttp\TestClientFactory::class, - Sdk::class => SdkFactory::class, + + Aws\Sdk::class => BehatTest\Common\Service\Aws\SdkFactory::class, ], ], - 'aws' => [ - 'region' => 'eu-west-1', - 'version' => 'latest', + + 'aws' => [ + 'region' => 'eu-west-1', + 'version' => 'latest', + 'DynamoDb' => [ 'endpoint' => 'https://dynamodb', ], ], - 'monolog' => [ - 'handlers' => [ + + 'monolog' => [ + 'handlers' => [ 'default' => [ // default configuration in normal operation - 'type' => 'test', + 'type' => 'test', 'processors' => [ 'psrLogProcessor', 'requestTracingProcessor', @@ -37,34 +37,39 @@ ], ], 'processors' => [ - 'psrLogProcessor' => [ - 'type' => 'psrLogMessage', + 'psrLogProcessor' => [ + 'type' => 'psrLogMessage', 'options' => [], // No options ], 'requestTracingProcessor' => [ - 'type' => RequestTracingLogProcessorFactory::class, + 'type' => \App\Service\Log\RequestTracingLogProcessorFactory::class, 'options' => [], // No options ], ], ], - 'repositories' => [ + + 'repositories' => [ 'dynamodb' => [ - 'actor-codes-table' => 'actor-codes', - 'actor-users-table' => 'actor-users', - 'viewer-codes-table' => 'viewer-codes', + 'actor-codes-table' => 'actor-codes', + 'actor-users-table' => 'actor-users', + 'viewer-codes-table' => 'viewer-codes', 'viewer-activity-table' => 'viewer-activity', - 'user-lpa-actor-map' => 'user-actor-lpa-map', + 'user-lpa-actor-map' => 'user-actor-lpa-map', ], ], - 'sirius_api' => [ + + 'sirius_api' => [ 'endpoint' => 'http://api-gateway-pact-mock', ], - 'codes_api' => [ - 'endpoint' => 'http://lpa-codes-pact-mock', + + 'codes_api' => [ + 'endpoint' => 'http://lpa-codes-pact-mock', 'static_auth_token' => getenv('LPA_CODES_STATIC_AUTH_TOKEN') ?: null, ], - 'iap_images_api' => [ + + 'iap_images_api' => [ 'endpoint' => 'http://iap-images-mock', ], - 'feature_flags' => [], + + 'feature_flags' => [], ]; diff --git a/service-api/app/features/bootstrap/container.acceptance.php b/service-api/app/features/bootstrap/container.acceptance.php index 2713fb97c2..87435266c9 100644 --- a/service-api/app/features/bootstrap/container.acceptance.php +++ b/service-api/app/features/bootstrap/container.acceptance.php @@ -12,7 +12,7 @@ new PhpFileProvider(realpath(__DIR__) . '/../../config/config.php'), // Load development config if it exists - new PhpFileProvider(realpath(__DIR__) . '/config.php'), + new PhpFileProvider(realpath(__DIR__) . '/config.php') ] ); diff --git a/service-api/app/features/context/Acceptance/CommonContext.php b/service-api/app/features/context/Acceptance/CommonContext.php index 3480b00402..ce65ccd0b7 100644 --- a/service-api/app/features/context/Acceptance/CommonContext.php +++ b/service-api/app/features/context/Acceptance/CommonContext.php @@ -9,6 +9,10 @@ use PHPUnit\Framework\Assert; /** + * Class CommonContext + * + * @package BehatTest\Context\UI + * * @property $traceId The X-Amzn-Trace-Id that gets attached to incoming requests by the AWS LB */ class CommonContext implements Context diff --git a/service-api/app/features/context/Acceptance/FeatureFlagContext.php b/service-api/app/features/context/Acceptance/FeatureFlagContext.php index 8598b748ec..7c2c9b92ea 100644 --- a/service-api/app/features/context/Acceptance/FeatureFlagContext.php +++ b/service-api/app/features/context/Acceptance/FeatureFlagContext.php @@ -36,7 +36,7 @@ public function setFeatureFlag(BeforeScenarioScope $scope): void throw new Exception('Feature flag values must be boolean'); } - $config = $this->base->container->get('config'); + $config = $this->base->container->get('config'); $config['feature_flags'][$tagParts[1]] = $flagValue; $this->base->container->set('config', $config); $this->base->container->set( diff --git a/service-api/app/features/context/Acceptance/LpaContext.php b/service-api/app/features/context/Acceptance/LpaContext.php index f08c66bc62..c1bb934ccc 100644 --- a/service-api/app/features/context/Acceptance/LpaContext.php +++ b/service-api/app/features/context/Acceptance/LpaContext.php @@ -72,7 +72,7 @@ public function aRecordOfMyActivationKeyRequestIsSaved(): void */ public function aRecordOfMyActivationKeyRequestIsUpdated(): void { - $dt = (new DateTime('now'))->add(new DateInterval('P1Y')); + $dt = (new DateTime('now'))->add(new \DateInterval('P1Y')); $lastCommand = $this->awsFixtures->getLastCommand(); Assert::assertEquals($lastCommand->getName(), 'UpdateItem'); @@ -1842,7 +1842,7 @@ public function iRequestToViewAnLPAWhichStatusIs($status) $response = $this->getResponseAsJson(); - if ($status === 'Revoked') { + if ($status == 'Revoked') { Assert::assertEmpty($response); } else { Assert::assertEquals($this->userLpaActorToken, $response['user-lpa-actor-token']); @@ -2643,7 +2643,7 @@ public function aRepeatRequestForALetterContainingAOneTimeUseCodeIsMade(): void 'SiriusUid' => $this->lpaUid, 'ActorId' => $this->actorId, 'Added' => (new DateTime())->format('Y-m-d\TH:i:s.u\Z'), - 'ActivateBy' => (new DateTime())->add(new DateInterval('P1Y'))->getTimestamp(), + 'ActivateBy' => (new DateTime())->add(new \DateInterval('P1Y'))->getTimestamp(), ] ), ], @@ -2662,7 +2662,7 @@ public function aRepeatRequestForALetterContainingAOneTimeUseCodeIsMade(): void 'SiriusUid' => $this->lpaUid, 'ActorId' => $this->actorId, 'Added' => (new DateTime())->format('Y-m-d\TH:i:s.u\Z'), - 'ActivateBy' => (new DateTime())->add(new DateInterval('P1Y'))->getTimestamp(), + 'ActivateBy' => (new DateTime())->add(new \DateInterval('P1Y'))->getTimestamp(), ] ), ] diff --git a/service-api/app/features/context/BaseAcceptanceContextTrait.php b/service-api/app/features/context/BaseAcceptanceContextTrait.php index 8e4ffd6430..2e435725e5 100644 --- a/service-api/app/features/context/BaseAcceptanceContextTrait.php +++ b/service-api/app/features/context/BaseAcceptanceContextTrait.php @@ -33,8 +33,8 @@ public function gatherContexts(BeforeScenarioScope $scope): void { $environment = $scope->getEnvironment(); - $this->base = $environment->getContext(BaseAcceptanceContext::class); - $this->ui = $this->base->ui; // MinkContext gathered in BaseUiContext + $this->base = $environment->getContext(BaseAcceptanceContext::class); + $this->ui = $this->base->ui; // MinkContext gathered in BaseUiContext $this->apiFixtures = $this->base->apiFixtures; $this->awsFixtures = $this->base->awsFixtures; } diff --git a/service-api/app/features/context/Integration/AccountContext.php b/service-api/app/features/context/Integration/AccountContext.php index 82c9cb5494..84e20201a7 100644 --- a/service-api/app/features/context/Integration/AccountContext.php +++ b/service-api/app/features/context/Integration/AccountContext.php @@ -20,6 +20,10 @@ use PHPUnit\Framework\ExpectationFailedException; /** + * Class AccountContext + * + * @package BehatTest\Context\Integration + * * @property $userAccountId * @property $userAccountEmail * @property $passwordResetData @@ -51,8 +55,8 @@ public function iAccessTheLoginForm(): void */ public function iAmAUserOfTheLpaApplication(): void { - $this->userAccountId = '123456789'; - $this->userAccountEmail = 'test@example.com'; + $this->userAccountId = '123456789'; + $this->userAccountEmail = 'test@example.com'; $this->userAccountPassword = 'pa33w0rd'; } @@ -62,7 +66,7 @@ public function iAmAUserOfTheLpaApplication(): void */ public function iAmCurrentlySignedIn(): void { - $this->password = 'pa33w0rd'; + $this->password = 'pa33w0rd'; $this->userAccountPassword = 'n3wPassWord'; // ActorUsers::getByEmail @@ -72,9 +76,9 @@ public function iAmCurrentlySignedIn(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, - 'Password' => password_hash($this->password, PASSWORD_DEFAULT, ['cost' => 13]), + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, + 'Password' => password_hash($this->password, PASSWORD_DEFAULT, ['cost' => 13]), 'LastLogin' => null, ] ), @@ -90,7 +94,7 @@ public function iAmCurrentlySignedIn(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, + 'Id' => $this->userAccountId, 'LastLogin' => null, ] ), @@ -145,7 +149,7 @@ public function iAmNotaUserOftheLpaApplication(): void */ public function iAmOnTheChangeEmailPage(): void { - $this->newEmail = 'newEmail@test.com'; + $this->newEmail = 'newEmail@test.com'; $this->userEmailResetToken = '12345abcde'; } @@ -188,10 +192,10 @@ public function iAmToldMyAccountHasNotBeenActivated(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, - 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), - 'LastLogin' => null, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, + 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), + 'LastLogin' => null, 'ActivationToken' => 'a12b3c4d5e', ] ), @@ -228,9 +232,9 @@ public function iAmToldMyCredentialsAreIncorrect(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, - 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, + 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), 'LastLogin' => null, ] ), @@ -306,7 +310,7 @@ public function iAskForMyPasswordToBeReset(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, + 'Id' => $this->userAccountId, 'Email' => $this->userAccountEmail, ] ), @@ -321,9 +325,9 @@ public function iAskForMyPasswordToBeReset(): void [ 'Attributes' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'PasswordResetToken' => $resetToken, - 'PasswordResetExpiry' => time() + (60 * 60 * 24), // 24 hours in the future + 'Id' => $this->userAccountId, + 'PasswordResetToken' => $resetToken, + 'PasswordResetExpiry' => time() + (60 * 60 * 24) // 24 hours in the future ] ), ] @@ -349,7 +353,7 @@ public function iAskToChangeMyPassword(): void public function iCannotEnterMyCurrentPassword(): void { $failedPassword = 'S0meS0rt0fPassw0rd'; - $newPassword = 'Successful-Raid-on-the-Cooki3s!'; + $newPassword = 'Successful-Raid-on-the-Cooki3s!'; // ActorUsers::get $this->awsFixtures->append( @@ -357,7 +361,7 @@ public function iCannotEnterMyCurrentPassword(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, + 'Id' => $this->userAccountId, 'Password' => password_hash($failedPassword, PASSWORD_DEFAULT, ['cost' => 13]), ] ), @@ -397,7 +401,7 @@ public function iChooseANewPassword(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, + 'Id' => $this->userAccountId, 'Email' => $this->userAccountEmail, ] ), @@ -412,8 +416,8 @@ public function iChooseANewPassword(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, 'PasswordResetExpiry' => $this->passwordResetData['PasswordResetExpiry'], ] ), @@ -482,13 +486,13 @@ public function iClickTheLinkToVerifyMyNewEmailAddress(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, - 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, + 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), 'EmailResetExpiry' => time() + (60 * 60), - 'LastLogin' => null, - 'NewEmail' => $this->newEmail, - 'EmailResetToken' => $this->userEmailResetToken, + 'LastLogin' => null, + 'NewEmail' => $this->newEmail, + 'EmailResetToken' => $this->userEmailResetToken, ] ), ] @@ -529,13 +533,13 @@ public function iClickTheLinkToVerifyMyNewEmailAddress(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, - 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), - 'EmailResetExpiry' => time() + (60 * 60), - 'LastLogin' => null, - 'NewEmail' => $this->newEmail, - 'EmailResetToken' => $this->userEmailResetToken, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, + 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), + 'EmailResetExpiry' => (time() + (60 * 60)), + 'LastLogin' => null, + 'NewEmail' => $this->newEmail, + 'EmailResetToken' => $this->userEmailResetToken, ] ), ] @@ -581,13 +585,13 @@ public function iClickTheLinkToVerifyMyNewEmailAddressAfterMyTokenHasExpired(): [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, - 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), - 'EmailResetExpiry' => time() - (60 * 60), - 'LastLogin' => null, - 'NewEmail' => $this->newEmail, - 'EmailResetToken' => $this->userEmailResetToken, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, + 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), + 'EmailResetExpiry' => (time() - (60 * 60)), + 'LastLogin' => null, + 'NewEmail' => $this->newEmail, + 'EmailResetToken' => $this->userEmailResetToken, ] ), ] @@ -619,7 +623,7 @@ public function iConfirmThatIWantToDeleteMyAccount(): void */ public function iCreateAnAccount(): void { - $this->userAccountEmail = 'hello@test.com'; + $this->userAccountEmail = 'hello@test.com'; $this->userAccountPassword = 'n3wPassWord!'; // ActorUsers::getByEmail @@ -643,7 +647,7 @@ public function iCreateAnAccount(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Email' => $this->userAccountEmail, + 'Email' => $this->userAccountEmail, 'ActivationToken' => '123456789', ] ), @@ -655,7 +659,7 @@ public function iCreateAnAccount(): void $this->createUserResponse = $us->add( [ - 'email' => $this->userAccountEmail, + 'email' => $this->userAccountEmail, 'password' => new HiddenString($this->userAccountPassword), ] ); @@ -667,7 +671,7 @@ public function iCreateAnAccount(): void public function iCreateAnAccountUsingDuplicateDetails(): void { $userAccountCreateData = [ - 'email' => 'hello@test.com', + 'email' => 'hello@test.com', 'password' => 'n3wPassWord!', ]; @@ -680,7 +684,7 @@ public function iCreateAnAccountUsingDuplicateDetails(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Email' => $userAccountCreateData['email'], + 'Email' => $userAccountCreateData['email'], 'Password' => $userAccountCreateData['password'], ] ), @@ -695,9 +699,9 @@ public function iCreateAnAccountUsingDuplicateDetails(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Email' => $userAccountCreateData['email'], + 'Email' => $userAccountCreateData['email'], 'Password' => $userAccountCreateData['password'], - 'Id' => $id, + 'Id' => $id, ] ), ], @@ -723,11 +727,11 @@ public function iCreateAnAccountUsingDuplicateDetails(): void public function iCreateAnAccountUsingDuplicateDetailsNotActivated(): void { $userAccountCreateData = [ - 'Id' => '1234567890abcdef', + 'Id' => '1234567890abcdef', 'ActivationToken' => 'activate1234567890', - 'ExpiresTTL' => '232424232244', - 'Email' => 'test@test.com', - 'Password' => 'Pa33w0rd', + 'ExpiresTTL' => '232424232244', + 'Email' => 'test@test.com', + 'Password' => 'Pa33w0rd', ]; // ActorUsers::getByEmail @@ -738,10 +742,10 @@ public function iCreateAnAccountUsingDuplicateDetailsNotActivated(): void $this->marshalAwsResultData( [ 'ActivationToken' => $userAccountCreateData['ActivationToken'], - 'Email' => $userAccountCreateData['Email'], - 'Password' => $userAccountCreateData['Password'], - 'Id' => $userAccountCreateData['Id'], - 'ExpiresTTL' => $userAccountCreateData['ExpiresTTL'], + 'Email' => $userAccountCreateData['Email'], + 'Password' => $userAccountCreateData['Password'], + 'Id' => $userAccountCreateData['Id'], + 'ExpiresTTL' => $userAccountCreateData['ExpiresTTL'], ] ), ], @@ -757,10 +761,10 @@ public function iCreateAnAccountUsingDuplicateDetailsNotActivated(): void $this->marshalAwsResultData( [ 'ActivationToken' => $userAccountCreateData['ActivationToken'], - 'ExpiresTTL' => $userAccountCreateData['ExpiresTTL'], - 'Email' => $userAccountCreateData['Email'], - 'Password' => $userAccountCreateData['Password'], - 'Id' => $userAccountCreateData['Id'], + 'ExpiresTTL' => $userAccountCreateData['ExpiresTTL'], + 'Email' => $userAccountCreateData['Email'], + 'Password' => $userAccountCreateData['Password'], + 'Id' => $userAccountCreateData['Id'], ] ), ], @@ -772,13 +776,13 @@ public function iCreateAnAccountUsingDuplicateDetailsNotActivated(): void $this->awsFixtures->append( new Result( [ - 'Item' - => $this->marshalAwsResultData( + 'Item' => + $this->marshalAwsResultData( [ 'ActivationToken' => $userAccountCreateData['ActivationToken'], - 'Email' => $userAccountCreateData['Email'], - 'Password' => $userAccountCreateData['Password'], - 'Id' => $userAccountCreateData['Id'], + 'Email' => $userAccountCreateData['Email'], + 'Password' => $userAccountCreateData['Password'], + 'Id' => $userAccountCreateData['Id'], ] ), ] @@ -790,7 +794,7 @@ public function iCreateAnAccountUsingDuplicateDetailsNotActivated(): void $result = $us->add( [ - 'email' => $userAccountCreateData['Email'], + 'email' => $userAccountCreateData['Email'], 'password' => new HiddenString($userAccountCreateData['Password']), ] ); @@ -803,10 +807,10 @@ public function iCreateAnAccountUsingDuplicateDetailsNotActivated(): void public function iCreateAnAccountUsingWithAnEmailAddressThatHasBeenRequestedForReset(): void { $userAccountCreateData = [ - 'Id' => 1, + 'Id' => 1, 'ActivationToken' => 'activate1234567890', - 'Email' => 'test@test.com', - 'Password' => 'Pa33w0rd', + 'Email' => 'test@test.com', + 'Password' => 'Pa33w0rd', ]; // ActorUsers::getByEmail @@ -825,13 +829,13 @@ public function iCreateAnAccountUsingWithAnEmailAddressThatHasBeenRequestedForRe 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => '123456789', - 'Email' => 'other@user.co.uk', - 'Password' => password_hash('passW0rd', PASSWORD_DEFAULT, ['cost' => 13]), - 'EmailResetExpiry' => time() + (60 * 60), - 'LastLogin' => null, - 'NewEmail' => 'test@test.com', - 'EmailResetToken' => 'abc1234567890', + 'Id' => '123456789', + 'Email' => 'other@user.co.uk', + 'Password' => password_hash('passW0rd', PASSWORD_DEFAULT, ['cost' => 13]), + 'EmailResetExpiry' => (time() + (60 * 60)), + 'LastLogin' => null, + 'NewEmail' => 'test@test.com', + 'EmailResetToken' => 'abc1234567890', ] ), ], @@ -925,7 +929,7 @@ public function iFollowMyUniqueExpiredInstructionsOnHowToResetMyPassword(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, + 'Id' => $this->userAccountId, 'Email' => $this->userAccountEmail, ] ), @@ -940,8 +944,8 @@ public function iFollowMyUniqueExpiredInstructionsOnHowToResetMyPassword(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, 'PasswordResetExpiry' => $this->passwordResetData['PasswordResetExpiry'], ] ), @@ -970,8 +974,9 @@ public function iFollowMyUniqueInstructionsOnHowToResetMyPassword(): void 'Items' => [ $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, + 'Id' => $this->userAccountId, 'Email' => $this->userAccountEmail, + ] ), ], @@ -985,8 +990,8 @@ public function iFollowMyUniqueInstructionsOnHowToResetMyPassword(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, 'PasswordResetExpiry' => $this->passwordResetData['PasswordResetExpiry'], ] ), @@ -1059,9 +1064,9 @@ public function iDoNotConfirmCancellationOfTheChosenViewerCode(): void public function iHaveAskedForMyPasswordToBeReset(): void { $this->passwordResetData = [ - 'Id' => $this->userAccountId, - 'PasswordResetToken' => 'AAAABBBBCCCC', - 'PasswordResetExpiry' => time() + (60 * 60 * 12), // 12 hours in the future + 'Id' => $this->userAccountId, + 'PasswordResetToken' => 'AAAABBBBCCCC', + 'PasswordResetExpiry' => time() + (60 * 60 * 12) // 12 hours in the future ]; } @@ -1071,11 +1076,11 @@ public function iHaveAskedForMyPasswordToBeReset(): void public function iHaveAskedToCreateANewAccount(): void { $this->actorAccountCreateData = [ - 'Id' => '123456789', - 'Email' => 'hello@test.com', - 'Password' => 'Pa33w0rd', - 'ActivationToken' => 'activate1234567890', - 'ActivationTokenExpiry' => time() + (60 * 60 * 12), // 12 hours in the future + 'Id' => '123456789', + 'Email' => 'hello@test.com', + 'Password' => 'Pa33w0rd', + 'ActivationToken' => 'activate1234567890', + 'ActivationTokenExpiry' => time() + (60 * 60 * 12) // 12 hours in the future ]; } @@ -1101,7 +1106,7 @@ public function iHaveNotActivatedMyAccount(): void public function iHaveRequestedToChangeMyEmailAddress(): void { $this->userEmailResetToken = '12345abcde'; - $this->newEmail = 'newEmail@test.com'; + $this->newEmail = 'newEmail@test.com'; } /** @@ -1125,7 +1130,7 @@ public function iProvideMyNewPassword(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, + 'Id' => $this->userAccountId, 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), ] ), @@ -1159,6 +1164,7 @@ public function iReceiveUniqueInstructionsOnHowToActivateMyAccount(): void Assert::assertArrayHasKey('Id', $this->createUserResponse); Assert::assertArrayHasKey('ActivationToken', $this->createUserResponse); Assert::assertArrayHasKey('ExpiresTTL', $this->createUserResponse); + } /** @@ -1180,8 +1186,8 @@ public function iRequestToChangeMyEmailToAUniqueEmailAddress(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), ] ), @@ -1202,12 +1208,12 @@ public function iRequestToChangeMyEmailToAUniqueEmailAddress(): void 'Item' => $this->marshalAwsResultData( [ 'EmailResetExpiry' => time() + (60 * 60 * 48), - 'Email' => $this->userAccountEmail, - 'LastLogin' => null, - 'Id' => $this->userAccountId, - 'NewEmail' => $this->newEmail, - 'EmailResetToken' => $this->userEmailResetToken, - 'Password' => $this->userAccountPassword, + 'Email' => $this->userAccountEmail, + 'LastLogin' => null, + 'Id' => $this->userAccountId, + 'NewEmail' => $this->newEmail, + 'EmailResetToken' => $this->userEmailResetToken, + 'Password' => $this->userAccountPassword, ] ), ] @@ -1226,8 +1232,8 @@ public function iRequestToChangeMyEmailToAnEmailAddressThat($context) [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), ] ), @@ -1243,7 +1249,7 @@ public function iRequestToChangeMyEmailToAnEmailAddressThat($context) 'Items' => [ $this->marshalAwsResultData( [ - 'Email' => $this->userAccountEmail, + 'Email' => $this->userAccountEmail, 'Password' => $this->userAccountPassword, ] ), @@ -1265,12 +1271,12 @@ public function iRequestToChangeMyEmailToAnEmailAddressThat($context) $this->marshalAwsResultData( [ 'EmailResetExpiry' => time() + (60 * 60), - 'Email' => 'another@user.com', - 'LastLogin' => null, - 'Id' => 'aaaaaa1111111', - 'NewEmail' => $this->newEmail, - 'EmailResetToken' => 't0ken12345', - 'Password' => 'otherU53rsPa55w0rd', + 'Email' => 'another@user.com', + 'LastLogin' => null, + 'Id' => 'aaaaaa1111111', + 'NewEmail' => $this->newEmail, + 'EmailResetToken' => 't0ken12345', + 'Password' => 'otherU53rsPa55w0rd', ] ), ], @@ -1287,12 +1293,12 @@ public function iRequestToChangeMyEmailToAnEmailAddressThat($context) $this->marshalAwsResultData( [ 'EmailResetExpiry' => time() - (60), - 'Email' => 'another@user.com', - 'LastLogin' => null, - 'Id' => 'aaaaaa1111111', - 'NewEmail' => $this->newEmail, - 'EmailResetToken' => 't0ken12345', - 'Password' => 'otherU53rsPa55w0rd', + 'Email' => 'another@user.com', + 'LastLogin' => null, + 'Id' => 'aaaaaa1111111', + 'NewEmail' => $this->newEmail, + 'EmailResetToken' => 't0ken12345', + 'Password' => 'otherU53rsPa55w0rd', ] ), ], @@ -1307,12 +1313,12 @@ public function iRequestToChangeMyEmailToAnEmailAddressThat($context) 'Item' => $this->marshalAwsResultData( [ 'EmailResetExpiry' => time() + (60 * 60 * 48), - 'Email' => $this->userAccountEmail, - 'LastLogin' => null, - 'Id' => $this->userAccountId, - 'NewEmail' => $this->newEmail, - 'EmailResetToken' => $this->userEmailResetToken, - 'Password' => $this->userAccountPassword, + 'Email' => $this->userAccountEmail, + 'LastLogin' => null, + 'Id' => $this->userAccountId, + 'NewEmail' => $this->newEmail, + 'EmailResetToken' => $this->userEmailResetToken, + 'Password' => $this->userAccountPassword, ] ), ] @@ -1351,8 +1357,8 @@ public function iRequestToChangeMyEmailWithAnIncorrectPassword(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), ] ), @@ -1430,7 +1436,7 @@ public function iShouldBeToldThatMyEmailCouldNotBeChanged(): void public function iShouldBeToldThatMyRequestWasSuccessful(): void { $userService = $this->container->get(UserService::class); - $response = $userService->requestChangeEmail( + $response = $userService->requestChangeEmail( $this->userAccountId, $this->newEmail, new HiddenString($this->userAccountPassword) @@ -1500,8 +1506,8 @@ public function myAccountIsDeleted(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), ] ), @@ -1515,9 +1521,9 @@ public function myAccountIsDeleted(): void [ 'Item' => $this->marshalAwsResultData( [ - 'Id' => $this->userAccountId, - 'Email' => $this->userAccountEmail, - 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), + 'Id' => $this->userAccountId, + 'Email' => $this->userAccountEmail, + 'Password' => password_hash($this->userAccountPassword, PASSWORD_DEFAULT, ['cost' => 13]), 'LastLogin' => null, ] ), diff --git a/service-api/app/features/context/Integration/BaseIntegrationContext.php b/service-api/app/features/context/Integration/BaseIntegrationContext.php index 77f7ae2752..fb7250a0bd 100644 --- a/service-api/app/features/context/Integration/BaseIntegrationContext.php +++ b/service-api/app/features/context/Integration/BaseIntegrationContext.php @@ -12,7 +12,10 @@ abstract class BaseIntegrationContext implements Context, Psr11AwareContext { - protected ContainerInterface|Container $container; + /** + * @var ContainerInterface|Container + */ + protected $container; /** * @inheritDoc @@ -31,6 +34,7 @@ final public function setContainer(ContainerInterface $container): void * what datatype things are. This function creates that data structure. * * @param array $input + * * @return array */ protected function marshalAwsResultData(array $input): array diff --git a/service-api/app/features/context/Integration/FeatureFlagContext.php b/service-api/app/features/context/Integration/FeatureFlagContext.php index 5817ad3aa3..94a04ebe3e 100644 --- a/service-api/app/features/context/Integration/FeatureFlagContext.php +++ b/service-api/app/features/context/Integration/FeatureFlagContext.php @@ -31,8 +31,8 @@ public function setFeatureFlag(BeforeScenarioScope $scope) throw new Exception('Feature flag values must be boolean'); } - $container = $scope->getEnvironment()->getContext(LpaContext::class)->container; - $config = $container->get('config'); + $container = $scope->getEnvironment()->getContext(LpaContext::class)->container; + $config = $container->get('config'); $config['feature_flags'][$tagParts[1]] = $flagValue; $container->set('config', $config); $container->set( diff --git a/service-api/app/features/context/Integration/LpaContext.php b/service-api/app/features/context/Integration/LpaContext.php index 5dfdda15da..af782e2b47 100644 --- a/service-api/app/features/context/Integration/LpaContext.php +++ b/service-api/app/features/context/Integration/LpaContext.php @@ -100,7 +100,7 @@ public function aLetterIsRequestedContainingAOneTimeUseCode(): void try { $olderLpaService->requestAccessByLetter($this->lpaUid, $this->actorLpaId, $this->userId); - } catch (ApiException) { + } catch (ApiException $exception) { throw new Exception('Failed to request access code letter'); } } @@ -128,7 +128,7 @@ public function aRepeatRequestForALetterContainingAOneTimeUseCodeIsMade(): void try { $olderLpaService->requestAccessByLetter($this->lpaUid, $this->actorLpaId, $this->userId, '00-0-0-0-00'); - } catch (ApiException) { + } catch (ApiException $exception) { throw new Exception('Failed to request access code letter'); } } @@ -150,7 +150,7 @@ public function aRecordOfMyActivationKeyRequestIsSaved(): void */ public function aRecordOfMyActivationKeyRequestIsUpdated(): void { - $dt = (new DateTime('now'))->add(new DateInterval('P1Y')); + $dt = (new DateTime('now'))->add(new \DateInterval('P1Y')); $lastCommand = $this->awsFixtures->getLastCommand(); Assert::assertEquals($lastCommand->getName(), 'UpdateItem'); @@ -219,10 +219,10 @@ public function coActorsHaveAlsoCreatedAccessCodesForTheSameLPA(): void public function iAmGivenAUniqueAccessCode(): void { $viewerCodeService = $this->container->get(ViewerCodeService::class); - $codeData = $viewerCodeService->addCode($this->userLpaActorToken, $this->userId, $this->organisation); + $codeData = $viewerCodeService->addCode($this->userLpaActorToken, $this->userId, $this->organisation); $codeExpiry = (new DateTime($codeData['expires']))->format('Y-m-d'); - $in30Days = (new DateTime('23:59:59 +30 days', new DateTimeZone('Europe/London')))->format('Y-m-d'); + $in30Days = (new DateTime('23:59:59 +30 days', new DateTimeZone('Europe/London')))->format('Y-m-d'); Assert::assertArrayHasKey('code', $codeData); Assert::assertNotNull($codeData['code']); @@ -311,7 +311,7 @@ public function iAttemptToAddTheSameLPAAgain(): void $addLpaService = $this->container->get(AddLpa::class); $expectedResponse = [ - 'donor' => [ + 'donor' => [ 'uId' => $this->lpa->donor->uId, 'firstname' => $this->lpa->donor->firstname, 'middlenames' => $this->lpa->donor->middlenames, @@ -367,7 +367,7 @@ public function iProvideTheAttorneyDetailsFromAValidPaperLPADocument(): void $this->lpa ); - $codeExists = new stdClass(); + $codeExists = new stdClass(); $codeExists->Created = null; $this->pactPostInteraction( @@ -706,7 +706,7 @@ function (CommandInterface $cmd, RequestInterface $req) { $this->userDob, $this->userId ); - } catch (Exception) { + } catch (Exception $ex) { throw new Exception('Lpa confirmation unsuccessful'); } @@ -967,7 +967,7 @@ public function iCanSeeThatNoOrganisationsHaveAccessToMyLPA(): void $this->awsFixtures->append(new Result()); $viewerCodeService = $this->container->get(ViewerCodeService::class); - $codes = $viewerCodeService->getCodes($this->userLpaActorToken, $this->userId); + $codes = $viewerCodeService->getCodes($this->userLpaActorToken, $this->userId); Assert::assertEmpty($codes); } @@ -1985,7 +1985,7 @@ public function iProvideTheDetailsFromAValidPaperDocumentThatAlreadyHasAnActivat $this->lpa ); - $codeExists = new stdClass(); + $codeExists = new stdClass(); $createdDate = (new DateTime())->modify('-14 days'); $activationKeyDueDate = DateTimeImmutable::createFromMutable($createdDate); @@ -2015,7 +2015,7 @@ public function iProvideTheDetailsFromAValidPaperDocumentThatAlreadyHasAnActivat Assert::assertEquals('LPA has an activation key already', $ex->getMessage()); Assert::assertEquals( [ - 'donor' => [ + 'donor' => [ 'uId' => $this->lpa->donor->uId, 'firstname' => $this->lpa->donor->firstname, 'middlenames' => $this->lpa->donor->middlenames, @@ -2165,7 +2165,7 @@ public function iRequestToViewAnLPAWhichStatusIs($status) $lpaData = $this->lpaService->getByUserLpaActorToken($this->userLpaActorToken, $this->userId); - if ($status === 'Revoked') { + if ($status == 'Revoked') { Assert::assertEmpty($lpaData); } else { Assert::assertEquals($this->lpa->uId, $lpaData['lpa']['uId']); @@ -2445,7 +2445,7 @@ public function theLPAIsRemoved(): void */ public function theLPAIsSuccessfullyAdded(): void { - $now = (new DateTime())->format('Y-m-d\TH:i:s.u\Z'); + $now = (new DateTime())->format('Y-m-d\TH:i:s.u\Z'); $this->userLpaActorToken = '13579'; // UserLpaActorMap::getUsersLpas @@ -2488,7 +2488,7 @@ public function theLPAIsSuccessfullyAdded(): void $this->userDob, $this->actorLpaId ); - } catch (Exception) { + } catch (Exception $ex) { throw new Exception('Lpa confirmation unsuccessful'); } @@ -2749,7 +2749,7 @@ public function iRequestForANewActivationKeyAgain(): void ); $addOlderLpa = $this->container->get(AddAccessForAllLpa::class); - $response = $addOlderLpa->validateRequest($this->userId, $data); + $response = $addOlderLpa->validateRequest($this->userId, $data); $expectedResponse = [ 'actor' => json_decode(json_encode($this->lpa->donor), true), @@ -2836,7 +2836,7 @@ public function iProvideTheDetailsFromAValidPaperLPAWhichIHaveAlreadyAddedToMyAc ); $expectedResponse = [ - 'donor' => [ + 'donor' => [ 'uId' => $this->lpa->donor->uId, 'firstname' => $this->lpa->donor->firstname, 'middlenames' => $this->lpa->donor->middlenames, @@ -3055,7 +3055,7 @@ public function iAmToldMyActivationKeyRequestHasBeenReceived(): void try { $olderLpaService->requestAccessAndCleanseByLetter((string)$this->lpaUid, $this->userId, 'notes'); - } catch (ApiException) { + } catch (ApiException $exception) { throw new Exception('Failed to request access code letter'); } } @@ -3089,7 +3089,7 @@ public function iConfirmDetailsOfTheFoundLPAAreCorrectAndFlagIsTurned($flagStatu $addOlderLpa = $this->container->get(AddAccessForAllLpa::class); - if ($flagStatus === 'ON') { + if ($flagStatus == 'ON') { try { $addOlderLpa->validateRequest($this->userId, $data); } catch (NotFoundException $ex) { diff --git a/service-api/app/features/context/UsesPactContextTrait.php b/service-api/app/features/context/UsesPactContextTrait.php index 0bec25e0ab..9b31ff7f52 100644 --- a/service-api/app/features/context/UsesPactContextTrait.php +++ b/service-api/app/features/context/UsesPactContextTrait.php @@ -51,7 +51,7 @@ protected function pactPostInteraction( string $uri, $requestBody, int $responseStatus, - $responseBody = [], + $responseBody = [] ): void { // Create request expectation $success = $this->pact->requestToWithParameters( @@ -72,7 +72,7 @@ protected function pactPostInteraction( $responseStatus, is_array($responseBody) ? $this->createTableNode($responseBody) : $responseBody ); - } catch (NoConsumerRequestDefined) { + } catch (NoConsumerRequestDefined $ex) { throw new ConnectionException('Unable to create response expectation'); } } @@ -90,7 +90,7 @@ protected function pactGetInteraction( string $uri, int $responseStatus, $responseBody = [], - string $query = '', + string $query = '' ): void { $this->pact->registerInteractionWithQueryAndBody( $providerName, diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodes.php b/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodes.php index 2e5fefbd88..c511337f55 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodes.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodes.php @@ -15,21 +15,10 @@ use GuzzleHttp\Psr7\Request; use Psr\Http\Message\ResponseInterface; -/** - * Class ActorCodes - * - * @package App\DataAccess\ApiGateway - */ class ActorCodes { private string $apiBaseUri; - private RequestSigner $awsSignature; - - private HttpClient $httpClient; - - private string $traceId; - /** * ActorCodes Constructor * @@ -38,12 +27,9 @@ class ActorCodes * @param string $apiUrl * @param string $traceId An amazon trace id to pass to subsequent services */ - public function __construct(HttpClient $httpClient, RequestSigner $awsSignature, string $apiUrl, string $traceId) + public function __construct(private HttpClient $httpClient, private RequestSigner $awsSignature, string $apiUrl, private string $traceId) { - $this->httpClient = $httpClient; $this->apiBaseUri = $apiUrl; - $this->awsSignature = $awsSignature; - $this->traceId = $traceId; } /** @@ -60,7 +46,7 @@ public function validateCode(string $code, string $uid, string $dob): ActorCode [ 'lpa' => $uid, 'dob' => $dob, - 'code' => $code + 'code' => $code, ] ); @@ -76,21 +62,16 @@ public function validateCode(string $code, string $uid, string $dob): ActorCode */ public function flagCodeAsUsed(string $code): void { - $this->makePostRequest('v1/revoke', [ 'code' => $code ]); + $this->makePostRequest('v1/revoke', ['code' => $code]); } - /** - * @param string $lpaId - * @param string $actorId - * @return ActorCode - */ public function checkActorHasCode(string $lpaId, string $actorId): ActorCode { $response = $this->makePostRequest( 'v1/exists', [ - 'lpa' => $lpaId, - 'actor' => $actorId + 'lpa' => $lpaId, + 'actor' => $actorId, ] ); @@ -108,7 +89,7 @@ public function checkActorHasCode(string $lpaId, string $actorId): ActorCode */ private function makePostRequest(string $url, array $body): ResponseInterface { - $url = sprintf("%s/%s", $this->apiBaseUri, $url); + $url = sprintf('%s/%s', $this->apiBaseUri, $url); $body = json_encode($body); $request = new Request('POST', $url, $this->buildHeaders(), $body); @@ -130,8 +111,8 @@ private function makePostRequest(string $url, array $body): ResponseInterface private function buildHeaders(): array { $headerLines = [ - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', ]; if (!empty($this->traceId)) { diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodesFactory.php b/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodesFactory.php index 84215ee192..22abab8f41 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodesFactory.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/ActorCodesFactory.php @@ -7,6 +7,7 @@ use App\Service\Log\RequestTracing; use GuzzleHttp\Client as HttpClient; use Psr\Container\ContainerInterface; +use Exception; class ActorCodesFactory { @@ -15,7 +16,7 @@ public function __invoke(ContainerInterface $container): ActorCodes $config = $container->get('config'); if (!isset($config['codes_api']['endpoint'])) { - throw new \Exception('Actor codes API Gateway endpoint is not set'); + throw new Exception('Actor codes API Gateway endpoint is not set'); } return new ActorCodes( diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/Lpas.php b/service-api/app/src/App/src/DataAccess/ApiGateway/Lpas.php index 66309d40c0..256d45db96 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/Lpas.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/Lpas.php @@ -24,33 +24,20 @@ /** * Looks up LPAs in the Sirius API Gateway. - * - * Class Lpas - * @package App\DataAccess\ApiGateway */ class Lpas implements LpasInterface { private string $apiBaseUri; - private AwsSignatureV4 $awsSignature; - private HttpClient $httpClient; - private LoggerInterface $logger; - private DataSanitiserStrategy $sanitiser; - private string $traceId; public function __construct( - HttpClient $httpClient, - AwsSignatureV4 $awsSignature, + private HttpClient $httpClient, + private AwsSignatureV4 $awsSignature, string $apiUrl, - string $traceId, - DataSanitiserStrategy $sanitiser, - LoggerInterface $logger + private string $traceId, + private DataSanitiserStrategy $sanitiser, + private LoggerInterface $logger, ) { - $this->httpClient = $httpClient; $this->apiBaseUri = $apiUrl; - $this->awsSignature = $awsSignature; - $this->traceId = $traceId; - $this->sanitiser = $sanitiser; - $this->logger = $logger; } /** @@ -75,7 +62,7 @@ public function get(string $uid): ?Response\LpaInterface */ public function lookup(array $uids): array { - $provider = AwsCredentialProvider::defaultProvider(); + $provider = AwsCredentialProvider::defaultProvider(); $credentials = $provider()->wait(); // Builds an array of Requests to send @@ -83,7 +70,7 @@ public function lookup(array $uids): array $requests = array_combine( $uids, // Use as array key array_map(function ($v) use ($credentials) { - $url = $this->apiBaseUri . sprintf("/v1/use-an-lpa/lpas/%s", $v); + $url = $this->apiBaseUri . sprintf('/v1/use-an-lpa/lpas/%s', $v); $request = new Request('GET', $url, $this->buildHeaders()); @@ -98,13 +85,13 @@ public function lookup(array $uids): array $pool = new Pool($this->httpClient, $requests, [ 'concurrency' => 50, - 'options' => [ + 'options' => [ 'http_errors' => false, ], - 'fulfilled' => function ($response, $id) use (&$results) { + 'fulfilled' => function ($response, $id) use (&$results) { $results[$id] = $response; }, - 'rejected' => function ($reason, $id) { + 'rejected' => function ($reason, $id) { // Log? }, ]); @@ -132,8 +119,8 @@ public function lookup(array $uids): array 'Unexpected {status} response from gateway for request of LPA {lpaUid}', [ 'event_code' => EventCodes::UNEXPECTED_DATA_LPA_API_RESPONSE, - 'status' => $statusCode, - 'lpaUid' => $uid, + 'status' => $statusCode, + 'lpaUid' => $uid, ] ); unset($results[$uid]); @@ -165,14 +152,14 @@ public function requestLetter(int $caseId, ?int $actorId, ?string $additionalInf $payloadContent['actor_uid'] = $actorId; } - $provider = AwsCredentialProvider::defaultProvider(); + $provider = AwsCredentialProvider::defaultProvider(); $credentials = $provider()->wait(); // request payload $body = json_encode($payloadContent); // construct request for API gateway - $url = $this->apiBaseUri . '/v1/use-an-lpa/lpas/requestCode'; + $url = $this->apiBaseUri . '/v1/use-an-lpa/lpas/requestCode'; $request = new Request('POST', $url, $this->buildHeaders(), $body); $request = $this->awsSignature->signRequest($request, $credentials); @@ -195,7 +182,7 @@ public function requestLetter(int $caseId, ?int $actorId, ?string $additionalInf private function buildHeaders(): array { $headerLines = [ - 'Content-Type' => 'application/json', + 'Content-Type' => 'application/json', ]; if (!empty($this->traceId)) { diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/LpasFactory.php b/service-api/app/src/App/src/DataAccess/ApiGateway/LpasFactory.php index 17ccb8efd8..66a73897e5 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/LpasFactory.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/LpasFactory.php @@ -10,6 +10,7 @@ use GuzzleHttp\Client as HttpClient; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; +use Exception; class LpasFactory { @@ -18,7 +19,7 @@ public function __invoke(ContainerInterface $container) $config = $container->get('config'); if (!isset($config['sirius_api']['endpoint'])) { - throw new \Exception('Sirius API Gateway endpoint is not set'); + throw new Exception('Sirius API Gateway endpoint is not set'); } return new Lpas( diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/RequestSigner.php b/service-api/app/src/App/src/DataAccess/ApiGateway/RequestSigner.php index dc22892367..5ee66c81d2 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/RequestSigner.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/RequestSigner.php @@ -10,14 +10,8 @@ class RequestSigner { - private ?string $staticAuthToken; - - private SignatureV4 $signer; - - public function __construct(SignatureV4 $signer, ?string $staticAuthToken = null) + public function __construct(private SignatureV4 $signer, private ?string $staticAuthToken = null) { - $this->signer = $signer; - $this->staticAuthToken = $staticAuthToken; } public function sign(RequestInterface $request): RequestInterface diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodes.php b/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodes.php index f715416998..1b3c1fca80 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodes.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodes.php @@ -11,25 +11,8 @@ class ActorCodes implements ActorCodesInterface { use DynamoHydrateTrait; - /** - * @var DynamoDbClient - */ - private $client; - - /** - * @var string - */ - private $actorLpaCodesTable; - - /** - * ViewerCodeActivity constructor. - * @param DynamoDbClient $client - * @param string $actorLpaCodesTable - */ - public function __construct(DynamoDbClient $client, string $actorLpaCodesTable) + public function __construct(private DynamoDbClient $client, private string $actorLpaCodesTable) { - $this->client = $client; - $this->actorLpaCodesTable = $actorLpaCodesTable; } /** @@ -39,7 +22,7 @@ public function get(string $code): ?array { $result = $this->client->getItem([ 'TableName' => $this->actorLpaCodesTable, - 'Key' => [ + 'Key' => [ 'ActorCode' => [ 'S' => $code, ], @@ -57,18 +40,18 @@ public function get(string $code): ?array public function flagCodeAsUsed(string $code) { $this->client->updateItem([ - 'TableName' => $this->actorLpaCodesTable, - 'Key' => [ + 'TableName' => $this->actorLpaCodesTable, + 'Key' => [ 'ActorCode' => [ 'S' => $code, ], ], - 'UpdateExpression' => 'set Active=:active', + 'UpdateExpression' => 'set Active=:active', 'ExpressionAttributeValues' => [ ':active' => [ 'BOOL' => false, ], - ] + ], ]); } } diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodesFactory.php b/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodesFactory.php index 3b7b53eaf8..56284f1de7 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodesFactory.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/ActorCodesFactory.php @@ -6,6 +6,7 @@ use Aws\DynamoDb\DynamoDbClient; use Psr\Container\ContainerInterface; +use Exception; class ActorCodesFactory { @@ -14,7 +15,7 @@ public function __invoke(ContainerInterface $container) $config = $container->get('config'); if (!isset($config['repositories']['dynamodb']['actor-codes-table'])) { - throw new \Exception('Actor Codes table configuration not present'); + throw new Exception('Actor Codes table configuration not present'); } return new ActorCodes( diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/ActorUsersFactory.php b/service-api/app/src/App/src/DataAccess/DynamoDb/ActorUsersFactory.php index b6bdacc4b3..11acf6954b 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/ActorUsersFactory.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/ActorUsersFactory.php @@ -6,6 +6,7 @@ use Aws\DynamoDb\DynamoDbClient; use Psr\Container\ContainerInterface; +use Exception; class ActorUsersFactory { @@ -14,7 +15,7 @@ public function __invoke(ContainerInterface $container) $config = $container->get('config'); if (!isset($config['repositories']['dynamodb']['actor-users-table'])) { - throw new \Exception('Actor Users table configuration not present'); + throw new Exception('Actor Users table configuration not present'); } return new ActorUsers( diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/UserLpaActorMap.php b/service-api/app/src/App/src/DataAccess/DynamoDb/UserLpaActorMap.php index 90f44e38ea..741be0c8e0 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/UserLpaActorMap.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/UserLpaActorMap.php @@ -156,7 +156,7 @@ public function delete(string $lpaActorToken): array */ public function activateRecord(string $lpaActorToken, string $actorId, string $activationCode): array { - $current = new DateTimeImmutable('now', new DateTimeZone('Etc/UTC')); + $current = new DateTimeImmutable('now', new DateTimeZone('Etc/UTC')); $activatedTime = $current->format(DateTimeInterface::ATOM); $response = $this->client->updateItem( diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivity.php b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivity.php index edf4274942..1b8e2076ef 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivity.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivity.php @@ -13,25 +13,8 @@ class ViewerCodeActivity implements ViewerCodeActivityInterface { use DynamoHydrateTrait; - /** - * @var DynamoDbClient - */ - private $client; - - /** - * @var string - */ - private $viewerActivityTable; - - /** - * ViewerCodeActivity constructor. - * @param DynamoDbClient $client - * @param string $viewerActivityTable - */ - public function __construct(DynamoDbClient $client, string $viewerActivityTable) + public function __construct(private DynamoDbClient $client, private string $viewerActivityTable) { - $this->client = $client; - $this->viewerActivityTable = $viewerActivityTable; } /** @@ -44,11 +27,11 @@ public function recordSuccessfulLookupActivity(string $activityCode, string $org $this->client->putItem([ 'TableName' => $this->viewerActivityTable, - 'Item' => [ - 'ViewerCode' => ['S' => $activityCode], - 'Viewed' => ['S' => $now], - 'ViewedBy' => ['S' => $organisation] - ] + 'Item' => [ + 'ViewerCode' => ['S' => $activityCode], + 'Viewed' => ['S' => $now], + 'ViewedBy' => ['S' => $organisation], + ], ]); } @@ -61,17 +44,17 @@ public function getStatusesForViewerCodes(array $viewerCodes): array foreach ($viewerCodes as $key => $code) { $result = $this->client->query([ - 'TableName' => $this->viewerActivityTable, - 'KeyConditionExpression' => 'ViewerCode = :code', + 'TableName' => $this->viewerActivityTable, + 'KeyConditionExpression' => 'ViewerCode = :code', 'ExpressionAttributeValues' => $marshaler->marshalItem([ - ':code' => $code['ViewerCode'] + ':code' => $code['ViewerCode'], ]), ]); if ($result['Count'] === 0) { $viewerCodes[$key]['Viewed'] = false; } else { - $viewerActivityDetails = $this->getDataCollection($result); + $viewerActivityDetails = $this->getDataCollection($result); $viewerCodes[$key]['Viewed'] = $viewerActivityDetails; } } diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivityFactory.php b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivityFactory.php index a707fb3213..f43eb2b90e 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivityFactory.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodeActivityFactory.php @@ -6,6 +6,7 @@ use Aws\DynamoDb\DynamoDbClient; use Psr\Container\ContainerInterface; +use Exception; class ViewerCodeActivityFactory { @@ -14,7 +15,7 @@ public function __invoke(ContainerInterface $container) $config = $container->get('config'); if (!isset($config['repositories']['dynamodb']['viewer-activity-table'])) { - throw new \Exception('Viewer Activity table configuration not present'); + throw new Exception('Viewer Activity table configuration not present'); } return new ViewerCodeActivity( diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodes.php b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodes.php index 42db6ea23b..bad228aa1e 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodes.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodes.php @@ -15,26 +15,8 @@ class ViewerCodes implements ViewerCodesInterface { use DynamoHydrateTrait; - /** - * @var DynamoDbClient - */ - private $client; - - /** - * @var string - */ - private $viewerCodesTable; - - /** - * ViewerCodeActivity constructor. - * - * @param DynamoDbClient $client - * @param string $viewerCodesTable - */ - public function __construct(DynamoDbClient $client, string $viewerCodesTable) + public function __construct(private DynamoDbClient $client, private string $viewerCodesTable) { - $this->client = $client; - $this->viewerCodesTable = $viewerCodesTable; } /** @@ -44,7 +26,7 @@ public function get(string $code): ?array { $result = $this->client->getItem([ 'TableName' => $this->viewerCodesTable, - 'Key' => [ + 'Key' => [ 'ViewerCode' => [ 'S' => $code, ], @@ -64,9 +46,9 @@ public function getCodesByLpaId(string $siriusUid): array $marshaler = new Marshaler(); $result = $this->client->query([ - 'TableName' => $this->viewerCodesTable, - 'IndexName' => 'SiriusUidIndex', - 'KeyConditionExpression' => 'SiriusUid = :uId', + 'TableName' => $this->viewerCodesTable, + 'IndexName' => 'SiriusUidIndex', + 'KeyConditionExpression' => 'SiriusUid = :uId', 'ExpressionAttributeValues' => $marshaler->marshalItem([ ':uId' => $siriusUid, ]), @@ -90,23 +72,23 @@ public function add( string $siriusUid, DateTime $expires, string $organisation, - ?int $actorId + ?int $actorId, ) { // The current DateTime, including microseconds $now = (new DateTime())->format('Y-m-d\TH:i:s.u\Z'); try { $this->client->putItem([ - 'TableName' => $this->viewerCodesTable, - 'Item' => [ - 'ViewerCode' => ['S' => $code], - 'UserLpaActor' => ['S' => $userLpaActorToken], - 'SiriusUid' => ['S' => $siriusUid], - 'Added' => ['S' => $now], - 'Expires' => ['S' => $expires->format('c')], + 'TableName' => $this->viewerCodesTable, + 'Item' => [ + 'ViewerCode' => ['S' => $code], + 'UserLpaActor' => ['S' => $userLpaActorToken], + 'SiriusUid' => ['S' => $siriusUid], + 'Added' => ['S' => $now], + 'Expires' => ['S' => $expires->format('c')], // We use 'c' so not to assume UTC. - 'Organisation' => ['S' => $organisation], - 'CreatedBy' => ['N' => (string)$actorId], + 'Organisation' => ['S' => $organisation], + 'CreatedBy' => ['N' => (string)$actorId], ], 'ConditionExpression' => 'attribute_not_exists(ViewerCode)', ]); @@ -125,18 +107,18 @@ public function cancel(string $code, DateTime $cancelledDate): bool { // Update the item by cancelling the code and setting cancelled date $this->client->updateItem([ - 'TableName' => $this->viewerCodesTable, - 'Key' => [ + 'TableName' => $this->viewerCodesTable, + 'Key' => [ 'ViewerCode' => [ 'S' => $code, ], ], - 'UpdateExpression' => 'SET Cancelled=:c', + 'UpdateExpression' => 'SET Cancelled=:c', 'ExpressionAttributeValues' => [ ':c' => [ 'S' => $cancelledDate->format('c'), - ] - ] + ], + ], ]); return true; @@ -149,21 +131,21 @@ public function removeActorAssociation(string $code, int $codeOwner): bool { // Update the item by removing association with userlpactor and setting the code owner $this->client->updateItem([ - 'TableName' => $this->viewerCodesTable, - 'Key' => [ + 'TableName' => $this->viewerCodesTable, + 'Key' => [ 'ViewerCode' => [ 'S' => $code, ], ], - 'UpdateExpression' => 'SET UserLpaActor=:c, CreatedBy=:d', + 'UpdateExpression' => 'SET UserLpaActor=:c, CreatedBy=:d', 'ExpressionAttributeValues' => [ ':c' => [ 'S' => '', ], ':d' => [ 'N' => (string)$codeOwner, - ] - ] + ], + ], ]); return true; diff --git a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodesFactory.php b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodesFactory.php index 00821888aa..bfb9291ea1 100644 --- a/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodesFactory.php +++ b/service-api/app/src/App/src/DataAccess/DynamoDb/ViewerCodesFactory.php @@ -6,6 +6,7 @@ use Aws\DynamoDb\DynamoDbClient; use Psr\Container\ContainerInterface; +use Exception; class ViewerCodesFactory { @@ -14,7 +15,7 @@ public function __invoke(ContainerInterface $container) $config = $container->get('config'); if (!isset($config['repositories']['dynamodb']['viewer-codes-table'])) { - throw new \Exception('Viewer Codes table configuration not present'); + throw new Exception('Viewer Codes table configuration not present'); } return new ViewerCodes( diff --git a/service-api/app/src/App/src/DataAccess/Repository/ActorUsersInterface.php b/service-api/app/src/App/src/DataAccess/Repository/ActorUsersInterface.php index 3c5e7fb96d..b7331acd0e 100644 --- a/service-api/app/src/App/src/DataAccess/Repository/ActorUsersInterface.php +++ b/service-api/app/src/App/src/DataAccess/Repository/ActorUsersInterface.php @@ -169,7 +169,6 @@ public function resetActivationDetails(string $id, HiddenString $password, int $ * * @param string $id * @param HiddenString $password - * * @return bool */ public function rehashPassword(string $id, HiddenString $password): bool; diff --git a/service-api/app/src/App/src/DataAccess/Repository/KeyCollisionException.php b/service-api/app/src/App/src/DataAccess/Repository/KeyCollisionException.php index a8525f44ad..abd5818919 100644 --- a/service-api/app/src/App/src/DataAccess/Repository/KeyCollisionException.php +++ b/service-api/app/src/App/src/DataAccess/Repository/KeyCollisionException.php @@ -4,7 +4,8 @@ namespace App\DataAccess\Repository; -class KeyCollisionException extends \RuntimeException -{ +use RuntimeException; +class KeyCollisionException extends RuntimeException +{ } diff --git a/service-api/app/src/App/src/DataAccess/Repository/Response/ActorCode.php b/service-api/app/src/App/src/DataAccess/Repository/Response/ActorCode.php index 53b29bd2c5..108b2c2939 100644 --- a/service-api/app/src/App/src/DataAccess/Repository/Response/ActorCode.php +++ b/service-api/app/src/App/src/DataAccess/Repository/Response/ActorCode.php @@ -8,24 +8,21 @@ final class ActorCode implements ActorCodeInterface { - /** * Array representing the LPA's data. * * @var array */ - private $data; + private array $data; /** * The datetime that the data was looked up in api codes service. - * - * @var DateTime */ - private $lookupTime; + private DateTime $lookupTime; public function __construct(?array $data, ?DateTime $lookupTime) { - $this->data = $data; + $this->data = $data; $this->lookupTime = $lookupTime; } diff --git a/service-api/app/src/App/src/DataAccess/Repository/Response/Lpa.php b/service-api/app/src/App/src/DataAccess/Repository/Response/Lpa.php index 1f8fe16f7d..d773554e07 100644 --- a/service-api/app/src/App/src/DataAccess/Repository/Response/Lpa.php +++ b/service-api/app/src/App/src/DataAccess/Repository/Response/Lpa.php @@ -8,24 +8,21 @@ final class Lpa implements LpaInterface { - /** * Array representing the LPA's data. * * @var array */ - private $data; + private array $data; /** * The datetime that the data was looked up in Sirius main database. - * - * @var DateTime */ - private $lookupTime; + private DateTime $lookupTime; public function __construct(?array $data, ?DateTime $lookupTime) { - $this->data = $data; + $this->data = $data; $this->lookupTime = $lookupTime; } diff --git a/service-api/app/src/App/src/DataAccess/Repository/ViewerCodeActivityInterface.php b/service-api/app/src/App/src/DataAccess/Repository/ViewerCodeActivityInterface.php index 356d7a8f2f..9d6e7e8908 100644 --- a/service-api/app/src/App/src/DataAccess/Repository/ViewerCodeActivityInterface.php +++ b/service-api/app/src/App/src/DataAccess/Repository/ViewerCodeActivityInterface.php @@ -8,7 +8,6 @@ * Interface for recording activity around the Viewer Code. * * Interface ViewerCodeActivityInterface - * @package App\DataAccess\Repository */ interface ViewerCodeActivityInterface { diff --git a/service-api/app/src/App/src/DataAccess/Repository/ViewerCodesInterface.php b/service-api/app/src/App/src/DataAccess/Repository/ViewerCodesInterface.php index f45fdf80f3..ed45d690b3 100644 --- a/service-api/app/src/App/src/DataAccess/Repository/ViewerCodesInterface.php +++ b/service-api/app/src/App/src/DataAccess/Repository/ViewerCodesInterface.php @@ -13,7 +13,6 @@ interface ViewerCodesInterface * Get a viewer code from the database * * @param string $code - * * @return array */ public function get(string $code): ?array; @@ -22,7 +21,6 @@ public function get(string $code): ?array; * Gets a list of viewer codes for a given LPA * * @param string $siriusUid - * * @return array */ public function getCodesByLpaId(string $siriusUid): array; @@ -37,7 +35,6 @@ public function getCodesByLpaId(string $siriusUid): array; * @param string $siriusUid * @param DateTime $expires * @param string $organisation - * * @return mixed */ public function add( @@ -46,7 +43,7 @@ public function add( string $siriusUid, DateTime $expires, string $organisation, - ?int $actorId + ?int $actorId, ); /** @@ -54,7 +51,6 @@ public function add( * * @param string $code * @param DateTime $cancelledDate - * * @return bool The code cancellation was successful or not */ public function cancel(string $code, DateTime $cancelledDate): bool; @@ -63,7 +59,6 @@ public function cancel(string $code, DateTime $cancelledDate): bool; * update a viewer code from the database * * @param string $code - * * @return bool */ public function removeActorAssociation(string $code, int $codeOwner): bool;