Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
12 | trait HasPreviousUrlTrait |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Get the URL for the previous request. |
||
17 | * |
||
18 | * @param mixed $fallback |
||
19 | * @return string |
||
20 | */ |
||
21 | public function previous($fallback = false) |
||
22 | { |
||
23 | $referrer = $this->getContext()->getHeaders()->get('referer'); |
||
24 | $url = $referrer ? $this->to($referrer) : $this->getPreviousUrlFromSession(); |
||
25 | if ($url) { |
||
26 | return $url; |
||
27 | } elseif ($fallback) { |
||
28 | return $this->to($fallback); |
||
29 | } else { |
||
30 | return $this->to('/'); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Get the previous URL from the session if possible. |
||
36 | * |
||
37 | * @return string|null |
||
38 | */ |
||
39 | protected function getPreviousUrlFromSession() |
||
42 | // $session = $this->getSession(); |
||
43 | // return $session ? $session->previousUrl() : null; |
||
46 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.