1 | <?php |
||
14 | class TraceUser |
||
15 | { |
||
16 | /** |
||
17 | * Rate Limiter |
||
18 | * |
||
19 | * @var \Illuminate\Cache\RateLimiter |
||
20 | */ |
||
21 | private $limiter; |
||
22 | |||
23 | /** |
||
24 | * Sets the Rate Limiter. |
||
25 | * |
||
26 | * @param \Illuminate\Cache\RateLimiter $limiter |
||
27 | */ |
||
28 | public function __construct(RateLimiter $limiter) |
||
32 | |||
33 | /** |
||
34 | * Handle an incoming request and trace the user |
||
35 | * if the current user is authenticated. |
||
36 | * |
||
37 | * @param \Illuminate\Http\Request $request |
||
38 | * @param \Closure $next |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function handle($request, Closure $next) |
||
57 | |||
58 | /** |
||
59 | * Stores the user request in the database. |
||
60 | * |
||
61 | * @param \Illuminate\Contracts\Auth\Authenticatable $user |
||
62 | * @param \Illuminate\Http\Request $request |
||
63 | * @param \Symfony\Component\HttpFoundation\Response $response |
||
64 | * |
||
65 | * @return \Protonemedia\LaravelTracer\UserRequest|null |
||
66 | */ |
||
67 | private function traceUserRequest(UserContract $user, Request $request, Response $response): ? UserRequest |
||
84 | |||
85 | /** |
||
86 | * Returns a boolean wether this request has been attemped to |
||
87 | * trace too many times. |
||
88 | * |
||
89 | * @param array $qualified |
||
90 | * @return boolean |
||
91 | */ |
||
92 | private function tooManyAttempts($qualified) : bool |
||
106 | |||
107 | /** |
||
108 | * Calls the callable method that can be specified in the config file. |
||
109 | * |
||
110 | * @param \Illuminate\Http\Request $request |
||
111 | * @param \Symfony\Component\HttpFoundation\Response $response |
||
112 | * |
||
113 | * @return boolean |
||
114 | */ |
||
115 | private function shouldTraceUser(Request $request, Response $response): bool |
||
123 | } |
||
124 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.