| Conditions | 4 |
| Paths | 4 |
| Total Lines | 63 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 49 | public function ssoAction(Request $httpRequest) |
||
| 50 | { |
||
| 51 | $logger = $this->get('logger'); |
||
| 52 | $logger->notice( |
||
| 53 | 'Received AuthnRequest on second-factor-only endpoint, started processing' |
||
| 54 | ); |
||
| 55 | |||
| 56 | $redirectBinding = $this->get('second_factor_only.http.redirect_binding'); |
||
| 57 | |||
| 58 | try { |
||
| 59 | $originalRequest = $redirectBinding->processRequest($httpRequest); |
||
| 60 | } catch (Exception $e) { |
||
| 61 | $logger->critical(sprintf('Could not process Request, error: "%s"', $e->getMessage())); |
||
| 62 | |||
| 63 | return $this->render( |
||
| 64 | 'SurfnetStepupGatewayGatewayBundle:Gateway:unrecoverableError.html.twig' |
||
| 65 | ); |
||
| 66 | } |
||
| 67 | |||
| 68 | $originalRequestId = $originalRequest->getRequestId(); |
||
| 69 | $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId); |
||
| 70 | $logger->notice(sprintf( |
||
| 71 | 'AuthnRequest processing complete, received AuthnRequest from "%s", request ID: "%s"', |
||
| 72 | $originalRequest->getServiceProvider(), |
||
| 73 | $originalRequest->getRequestId() |
||
| 74 | )); |
||
| 75 | |||
| 76 | $stateHandler = $this->get('gateway.proxy.state_handler'); |
||
| 77 | |||
| 78 | $stateHandler |
||
| 79 | ->setRequestId($originalRequestId) |
||
| 80 | ->setRequestServiceProvider($originalRequest->getServiceProvider()) |
||
| 81 | ->setRelayState($httpRequest->get(AuthnRequest::PARAMETER_RELAY_STATE, '')) |
||
| 82 | ->setResponseAction('SurfnetStepupGatewaySecondFactorOnlyBundle:SecondFactorOnly:respond') |
||
| 83 | ->setResponseContextServiceId(static::RESPONSE_CONTEXT_SERVICE_ID); |
||
| 84 | |||
| 85 | // Check if the NameID is provided and we may use it. |
||
| 86 | $nameId = $originalRequest->getNameId(); |
||
| 87 | if (!$this->verifyNameId($originalRequest->getServiceProvider(), $nameId, $logger)) { |
||
| 88 | $responseRendering = $this->get('gateway.service.saml_response'); |
||
| 89 | return $responseRendering->renderRequesterFailureResponse( |
||
| 90 | $this->get(static::RESPONSE_CONTEXT_SERVICE_ID) |
||
| 91 | ); |
||
| 92 | } |
||
| 93 | $stateHandler->saveIdentityNameId($nameId); |
||
| 94 | |||
| 95 | // Check if the requested Loa is provided and supported. |
||
| 96 | $authnContextClassRef = $originalRequest->getAuthenticationContextClassRef(); |
||
| 97 | if (!$this->verifyAuthnContextClassRef($authnContextClassRef, $logger)) { |
||
| 98 | $responseRendering = $this->get('gateway.service.saml_response'); |
||
| 99 | return $responseRendering->renderRequesterFailureResponse( |
||
| 100 | $this->get(static::RESPONSE_CONTEXT_SERVICE_ID) |
||
| 101 | ); |
||
| 102 | } |
||
| 103 | $stateHandler->setRequestAuthnContextClassRef($authnContextClassRef); |
||
| 104 | |||
| 105 | $logger->notice( |
||
| 106 | 'Forwarding to second factor controller for loa determination and handling' |
||
| 107 | ); |
||
| 108 | return $this->forward( |
||
| 109 | 'SurfnetStepupGatewayGatewayBundle:Selection:selectSecondFactorForVerification' |
||
| 110 | ); |
||
| 111 | } |
||
| 112 | |||
| 234 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.