| Conditions | 15 |
| Paths | 16 |
| Total Lines | 52 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| 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 |
||
| 97 | public function collect(Request $request, Response $response, \Exception $exception = null) |
||
| 98 | { |
||
| 99 | $image = base64_encode(file_get_contents($this->kernel->locateResource('@KuleuvenAuthenticationBundle/Resources/images/shibboleth.png'))); |
||
| 100 | $this->data = array_replace($this->data, [ |
||
| 101 | 'image' => $image, |
||
| 102 | 'shibboleth' => [ |
||
| 103 | 'username' => $this->shibbolethServiceProvider->getUsername(), |
||
| 104 | 'authenticated' => $this->shibbolethServiceProvider->isAuthenticated(), |
||
| 105 | 'handlerPath' => $this->shibbolethServiceProvider->getHandlerPath(), |
||
| 106 | 'statusPath' => $this->shibbolethServiceProvider->getStatusPath(), |
||
| 107 | 'sessionLoginPath' => $this->shibbolethServiceProvider->getSessionLoginPath(), |
||
| 108 | 'sessionLogoutPath' => $this->shibbolethServiceProvider->getSessionLogoutPath(), |
||
| 109 | 'sessionOverviewPath' => $this->shibbolethServiceProvider->getSessionOverviewPath(), |
||
| 110 | 'handlerUrl' => $this->shibbolethServiceProvider->getHandlerUrl(), |
||
| 111 | 'statusUrl' => $this->shibbolethServiceProvider->getStatusUrl(), |
||
| 112 | 'loginUrl' => $this->shibbolethServiceProvider->getLoginUrl(), |
||
| 113 | 'logoutUrl' => $this->shibbolethServiceProvider->getLogoutUrl(), |
||
| 114 | 'overviewUrl' => $this->shibbolethServiceProvider->getOverviewUrl(), |
||
| 115 | 'reachable' => $this->shibbolethServiceProvider->isReachable(), |
||
| 116 | 'securedHandler' => $this->shibbolethServiceProvider->isSecuredHandler(), |
||
| 117 | 'usernameAttribute' => $this->shibbolethServiceProvider->getUsernameAttribute(), |
||
| 118 | 'authenticatedAttribute' => $this->shibbolethServiceProvider->getAuthenticatedAttribute(), |
||
| 119 | 'logoutUrlAttribute' => $this->shibbolethServiceProvider->getLogoutUrlAttribute(), |
||
| 120 | 'authenticationRequirements' => $this->shibbolethServiceProvider->getAuthenticationRequirements(), |
||
| 121 | 'defaultCharset' => $this->shibbolethServiceProvider->getDefaultCharset(), |
||
| 122 | 'attributes' => $this->shibbolethServiceProvider->getAttributes(), |
||
| 123 | ], |
||
| 124 | ]); |
||
| 125 | |||
| 126 | $token = $this->findToken(); |
||
| 127 | $user = (!empty($token) ? $token->getUser() : null); |
||
| 128 | $sourceToken = $this->findSourceToken(); |
||
| 129 | $source = (!empty($sourceToken) ? $sourceToken->getUser() : null); |
||
| 130 | |||
| 131 | $shibbolethUser = (empty($source) ? $user : $source); |
||
| 132 | $impersonatedUser = (empty($source) ? null : $user); |
||
| 133 | |||
| 134 | $this->data = array_replace($this->data, [ |
||
| 135 | 'enabled' => $this->firewallHelper->isProtectedBy(ShibbolethAuthenticationListener::class), |
||
| 136 | 'authenticated' => $this->shibbolethServiceProvider->isAuthenticated(), |
||
| 137 | 'user' => ($shibbolethUser instanceof UserInterface ? $shibbolethUser->getUsername() : $shibbolethUser), |
||
| 138 | 'display_name' => ($shibbolethUser instanceof KuleuvenUser ? $shibbolethUser->getDisplayName() : ''), |
||
| 139 | 'affiliation' => ($shibbolethUser instanceof KuleuvenUser ? $shibbolethUser->getAffiliation() : ''), |
||
| 140 | 'attributes' => ($shibbolethUser instanceof KuleuvenUser ? $shibbolethUser->getAttributes() : []), |
||
| 141 | 'token_class' => (!empty($token) ? get_class($token) : ''), |
||
| 142 | 'impersonated_user' => ($impersonatedUser instanceof UserInterface ? $impersonatedUser->getUsername() : $impersonatedUser), |
||
| 143 | 'impersonated_display_name' => ($impersonatedUser instanceof KuleuvenUser ? $impersonatedUser->getDisplayName() : ''), |
||
| 144 | 'impersonated_affiliation' => ($impersonatedUser instanceof KuleuvenUser ? $impersonatedUser->getAffiliation() : ''), |
||
| 145 | 'impersonated_attributes' => ($impersonatedUser instanceof KuleuvenUser ? $impersonatedUser->getAttributes() : []), |
||
| 146 | 'impersonated_token_class' => (!empty($sourceToken) ? get_class($sourceToken) : ''), |
||
| 147 | ]); |
||
| 148 | } |
||
| 149 | |||
| 294 |