| Conditions | 11 |
| Paths | 9 |
| Total Lines | 31 |
| 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 |
||
| 30 | protected function determineTargetUrl(Request $request) |
||
| 31 | { |
||
| 32 | if ($this->options['always_use_default_target_path']) { |
||
| 33 | return $this->options['default_target_path']; |
||
| 34 | } |
||
| 35 | |||
| 36 | if ($targetUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['target_path_parameter'])) { |
||
| 37 | if (preg_match('/^https?:\\\\/i', $targetUrl)) { |
||
| 38 | $targetUrl = '/'; |
||
| 39 | } |
||
| 40 | |||
| 41 | return $targetUrl; |
||
| 42 | } |
||
| 43 | |||
| 44 | if (null !== $this->providerKey && $targetUrl = $this->getTargetPath($request->getSession(), $this->providerKey)) { |
||
|
|
|||
| 45 | $this->removeTargetPath($request->getSession(), $this->providerKey); |
||
| 46 | |||
| 47 | return $targetUrl; |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) { |
||
| 51 | if (false !== $pos = strpos($targetUrl, '?')) { |
||
| 52 | $targetUrl = substr($targetUrl, 0, $pos); |
||
| 53 | } |
||
| 54 | if ($targetUrl && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) { |
||
| 55 | return $targetUrl; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | return $this->options['default_target_path']; |
||
| 60 | } |
||
| 61 | |||
| 63 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: