| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function getReferer(Request $request): string |
||
| 12 | { |
||
| 13 | $referer = $request->header('referer', ''); |
||
| 14 | |||
| 15 | if (empty($referer)) { |
||
| 16 | return ''; |
||
| 17 | } |
||
| 18 | |||
| 19 | $refererHost = Url::host($referer); |
||
|
|
|||
| 20 | |||
| 21 | if (empty($refererHost)) { |
||
| 22 | return ''; |
||
| 23 | } |
||
| 24 | |||
| 25 | if ($refererHost === $request->getHost()) { |
||
| 26 | return ''; |
||
| 27 | } |
||
| 28 | |||
| 29 | return $refererHost; |
||
| 30 | } |
||
| 31 | } |
||
| 32 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.