Conditions | 3 |
Paths | 6 |
Total Lines | 51 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php declare(strict_types=1); |
||
82 | public function verify(HTTPRequest $request, StoreInterface $store, RegisteredMethod $registeredMethod): Result |
||
83 | { |
||
84 | $options = $this->getCredentialRequestOptions($store, $registeredMethod); |
||
85 | |||
86 | $data = json_decode($request->getBody(), true); |
||
87 | |||
88 | // CBOR |
||
89 | $decoder = new Decoder(new TagObjectManager(), new OtherObjectManager()); |
||
90 | |||
91 | // Attestation statement support manager |
||
92 | $attestationStatementSupportManager = new AttestationStatementSupportManager(); |
||
93 | $attestationStatementSupportManager->add(new NoneAttestationStatementSupport()); |
||
94 | $attestationStatementSupportManager->add(new FidoU2FAttestationStatementSupport($decoder)); |
||
95 | |||
96 | // Attestation object loader |
||
97 | $attestationObjectLoader = new AttestationObjectLoader($attestationStatementSupportManager, $decoder); |
||
98 | |||
99 | $publicKeyCredentialLoader = new PublicKeyCredentialLoader($attestationObjectLoader, $decoder); |
||
100 | |||
101 | $credentialRepository = new CredentialRepository($store->getMember(), $registeredMethod); |
||
102 | |||
103 | $authenticatorAssertionResponseValidator = new AuthenticatorAssertionResponseValidator( |
||
104 | $credentialRepository, |
||
105 | $decoder, |
||
106 | new TokenBindingNotSupportedHandler(), |
||
107 | new ExtensionOutputCheckerHandler() |
||
108 | ); |
||
109 | |||
110 | // Create a PSR-7 request |
||
111 | $psrRequest = ServerRequest::fromGlobals(); |
||
112 | |||
113 | try { |
||
114 | $publicKeyCredential = $publicKeyCredentialLoader->load(base64_decode($data['credentials'])); |
||
115 | $response = $publicKeyCredential->getResponse(); |
||
116 | |||
117 | if (!$response instanceof AuthenticatorAssertionResponse) { |
||
118 | throw new ResponseTypeException('Unexpected response type found'); |
||
119 | } |
||
120 | |||
121 | $authenticatorAssertionResponseValidator->check( |
||
122 | $publicKeyCredential->getRawId(), |
||
123 | $publicKeyCredential->getResponse(), |
||
124 | $options, |
||
125 | $psrRequest, |
||
126 | (string) $store->getMember()->ID |
||
127 | ); |
||
128 | |||
129 | return Result::create(); |
||
130 | } catch (Exception $e) { |
||
131 | $this->logger->error($e->getMessage()); |
||
132 | throw $e; |
||
133 | } |
||
186 |