1 | <?php |
||
20 | class MobileRedirect |
||
21 | { |
||
22 | /** |
||
23 | * Mobile base url. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $baseUrl; |
||
28 | |||
29 | /** |
||
30 | * Keep url path when redirect to `baseUrl`. |
||
31 | * |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $keepPath; |
||
35 | |||
36 | /** |
||
37 | * Methods should redirect. |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $methods; |
||
42 | |||
43 | /** |
||
44 | * Redirect status code. |
||
45 | * |
||
46 | * @var int |
||
47 | */ |
||
48 | protected $statusCode; |
||
49 | |||
50 | /** |
||
51 | * Create new MobileRedirect instance. |
||
52 | * |
||
53 | * @param string $baseUrl |
||
54 | * @param bool $keepPath |
||
55 | * @param int $statusCode |
||
56 | */ |
||
57 | public function __construct(string $baseUrl, bool $keepPath, int $statusCode, array $methods) |
||
64 | |||
65 | /** |
||
66 | * Redirect to mobile site if end-user not using desktop device. |
||
67 | * |
||
68 | * @param \Illuminate\Http\Request $request |
||
69 | * @param \Closure $next |
||
70 | * @return mixed |
||
71 | */ |
||
72 | public function handle($request, Closure $next) |
||
80 | |||
81 | /** |
||
82 | * Return should redirect or not by request given. |
||
83 | * |
||
84 | * @param \Illuminate\Http\Request $request |
||
85 | * @return bool |
||
86 | */ |
||
87 | protected function shouldRedirect($request): bool |
||
93 | |||
94 | /** |
||
95 | * Get url for request. |
||
96 | * |
||
97 | * @param \Illuminate\Http\Request $request |
||
98 | * @return string |
||
99 | */ |
||
100 | protected function getUrlFor($request): string |
||
114 | } |
||
115 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.