| Conditions | 12 | 
| Paths | 145 | 
| Total Lines | 56 | 
| Code Lines | 36 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 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  | 
            ||
| 47 | public function forbidden(Request $request): Template  | 
            ||
| 48 |     { | 
            ||
| 49 |         $stateId = $request->query->get('StateId', false); | 
            ||
| 50 |         if (!is_string($stateId)) { | 
            ||
| 51 |             throw new Error\BadRequest('Missing required StateId query parameter.'); | 
            ||
| 52 | }  | 
            ||
| 53 | |||
| 54 | /** @var array $state */  | 
            ||
| 55 | $state = Auth\State::loadState($stateId, 'authorize:Authorize');  | 
            ||
| 56 | |||
| 57 | $t = new Template($this->config, 'authorize:authorize_403.twig');  | 
            ||
| 58 |         if (isset($state['Source']['auth'])) { | 
            ||
| 59 | $t->data['source'] = $state['Source']['auth'];  | 
            ||
| 60 | }  | 
            ||
| 61 |         if (isset($state['authprocAuthorize_reject_msg'])) { | 
            ||
| 62 | $t->data['reject_msg'] = $state['authprocAuthorize_reject_msg'];  | 
            ||
| 63 | }  | 
            ||
| 64 | |||
| 65 |         if (isset($state['Source']['auth'])) { | 
            ||
| 66 | $t->data['LogoutURL'] = Module::getModuleURL(  | 
            ||
| 67 | 'core/logout/' . urlencode($state['Source']['auth']),  | 
            ||
| 68 | );  | 
            ||
| 69 | }  | 
            ||
| 70 |         if (isset($state['authprocAuthorize_user_attribute'])) { | 
            ||
| 71 | $t->data['user_attribute'] = $state['authprocAuthorize_user_attribute'];  | 
            ||
| 72 | }  | 
            ||
| 73 | |||
| 74 | $t->data['allow_reauthentication'] = $state['authprocAuthorize_allow_re_authenticate_on_unauthorized'] ?? false;  | 
            ||
| 75 | $stateId = Auth\State::saveState($state, 'authorize:Authorize');  | 
            ||
| 76 | $t->data['url_reauthentication'] =  | 
            ||
| 77 |             Module::getModuleURL('authorize/error/reauthenticate', ['StateId' => $stateId]); | 
            ||
| 78 | |||
| 79 | if (  | 
            ||
| 80 | isset($state['authprocAuthorize_errorURL'])  | 
            ||
| 81 | && $state['authprocAuthorize_errorURL'] === true  | 
            ||
| 82 | && isset($state['Source']['errorURL'])  | 
            ||
| 83 |         ) { | 
            ||
| 84 | $errorURL = $state['Source']['errorURL'];  | 
            ||
| 85 |             $errorURL = str_replace('ERRORURL_CODE', 'AUTHORIZATION_FAILURE', $errorURL); | 
            ||
| 86 |             if (isset($state['saml:sp:State']['core:SP'])) { | 
            ||
| 87 |                 $errorURL = str_replace('ERRORURL_RP', urlencode($state['saml:sp:State']['core:SP']), $errorURL); | 
            ||
| 88 | }  | 
            ||
| 89 |             if (isset($state['saml:AuthnInstant'])) { | 
            ||
| 90 |                 $errorURL = str_replace('ERRORURL_TS', $state['saml:AuthnInstant'], $errorURL); | 
            ||
| 91 |             } else { | 
            ||
| 92 |                 $errorURL = str_replace('ERRORURL_TS', strval(time()), $errorURL); | 
            ||
| 93 | }  | 
            ||
| 94 |             $errorURL = str_replace('ERRORURL_TID', urlencode($this->session->getTrackID()), $errorURL); | 
            ||
| 95 |             if (isset($state['authprocAuthorize_ctx'])) { | 
            ||
| 96 |                 $errorURL = str_replace('ERRORURL_CTX', urlencode($state['authprocAuthorize_ctx']), $errorURL); | 
            ||
| 97 | }  | 
            ||
| 98 | $t->data['errorURL'] = $errorURL;  | 
            ||
| 99 | }  | 
            ||
| 100 | |||
| 101 | $t->setStatusCode(403);  | 
            ||
| 102 | return $t;  | 
            ||
| 103 | }  | 
            ||
| 129 |