| 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); |
||
| 76 | public function verify(HTTPRequest $request, StoreInterface $store, RegisteredMethod $registeredMethod): Result |
||
| 77 | { |
||
| 78 | $options = $this->getCredentialRequestOptions($store, $registeredMethod); |
||
| 79 | |||
| 80 | $data = json_decode($request->getBody(), true); |
||
| 81 | |||
| 82 | // CBOR |
||
| 83 | $decoder = new Decoder(new TagObjectManager(), new OtherObjectManager()); |
||
| 84 | |||
| 85 | // Attestation statement support manager |
||
| 86 | $attestationStatementSupportManager = new AttestationStatementSupportManager(); |
||
| 87 | $attestationStatementSupportManager->add(new NoneAttestationStatementSupport()); |
||
| 88 | $attestationStatementSupportManager->add(new FidoU2FAttestationStatementSupport($decoder)); |
||
| 89 | |||
| 90 | // Attestation object loader |
||
| 91 | $attestationObjectLoader = new AttestationObjectLoader($attestationStatementSupportManager, $decoder); |
||
| 92 | |||
| 93 | $publicKeyCredentialLoader = new PublicKeyCredentialLoader($attestationObjectLoader, $decoder); |
||
| 94 | |||
| 95 | $credentialRepository = new CredentialRepository($store->getMember(), $registeredMethod); |
||
| 96 | |||
| 97 | $authenticatorAssertionResponseValidator = new AuthenticatorAssertionResponseValidator( |
||
| 98 | $credentialRepository, |
||
| 99 | $decoder, |
||
| 100 | new TokenBindingNotSupportedHandler(), |
||
| 101 | new ExtensionOutputCheckerHandler() |
||
| 102 | ); |
||
| 103 | |||
| 104 | // Create a PSR-7 request |
||
| 105 | $psrRequest = ServerRequest::fromGlobals(); |
||
| 106 | |||
| 107 | try { |
||
| 108 | $publicKeyCredential = $publicKeyCredentialLoader->load(base64_decode($data['credentials'])); |
||
| 109 | $response = $publicKeyCredential->getResponse(); |
||
| 110 | |||
| 111 | if (!$response instanceof AuthenticatorAssertionResponse) { |
||
| 112 | throw new ResponseTypeException('Unexpected response type found'); |
||
| 113 | } |
||
| 114 | |||
| 115 | $authenticatorAssertionResponseValidator->check( |
||
| 116 | $publicKeyCredential->getRawId(), |
||
| 117 | $publicKeyCredential->getResponse(), |
||
| 118 | $options, |
||
| 119 | $psrRequest, |
||
| 120 | (string) $store->getMember()->ID |
||
| 121 | ); |
||
| 122 | |||
| 123 | return Result::create(); |
||
| 124 | } catch (Exception $e) { |
||
| 125 | $this->logger->error($e->getMessage()); |
||
| 126 | throw $e; |
||
| 127 | } |
||
| 180 |