Conditions | 16 |
Paths | 15 |
Total Lines | 48 |
Code Lines | 27 |
Lines | 9 |
Ratio | 18.75 % |
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 |
||
134 | public function onKernelResponse(FilterResponseEvent $event) |
||
135 | { |
||
136 | if (!$this->isEnabled() || HttpKernel::MASTER_REQUEST !== $event->getRequestType()) { |
||
137 | return; |
||
138 | } |
||
139 | |||
140 | $response = $event->getResponse(); |
||
141 | $request = $event->getRequest(); |
||
142 | $session = $request->getSession(); |
||
143 | $url = $event->getRequest()->getRequestUri(); |
||
144 | $token = $this->tokenStorage->getToken(); |
||
145 | |||
146 | if (null !== $token && method_exists($token, 'getProviderKey')) { |
||
147 | $key = $token->getProviderKey(); |
||
148 | } else { |
||
149 | $key = $this->adminFirewallName; |
||
150 | } |
||
151 | |||
152 | // Only enable toolbar when the kunstmaan_admin.toolbar_firewall_names config value contains the current firewall name. |
||
153 | if (!\in_array($key, $this->providerKeys, false)) { |
||
154 | return false; |
||
155 | } |
||
156 | |||
157 | // Only enable toolbar when we can find an authenticated user in the session from the kunstmaan_admin.admin_firewall_name config value. |
||
158 | $authenticated = false; |
||
159 | /** @var PostAuthenticationGuardToken $token */ |
||
160 | if ($session->has(sprintf('_security_%s', $this->adminFirewallName))) { |
||
161 | $token = unserialize($session->get(sprintf('_security_%s', $this->adminFirewallName))); |
||
162 | $authenticated = $token->isAuthenticated(); |
||
163 | } |
||
164 | |||
165 | // Do not capture redirects or modify XML HTTP Requests |
||
166 | if (!$authenticated || !$event->isMasterRequest() || $request->isXmlHttpRequest() || $this->adminRouteHelper->isAdminRoute($url)) { |
||
167 | return; |
||
168 | } |
||
169 | |||
170 | View Code Duplication | if ($response->isRedirection() || ($response->headers->has('Content-Type') && false === strpos( |
|
171 | $response->headers->get('Content-Type'), |
||
172 | 'html' |
||
173 | )) |
||
174 | || 'html' !== $request->getRequestFormat() |
||
175 | || false !== stripos($response->headers->get('Content-Disposition'), 'attachment;') |
||
176 | ) { |
||
177 | return; |
||
178 | } |
||
179 | |||
180 | $this->injectToolbar($response, $request); |
||
181 | } |
||
182 | |||
208 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..