Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | abstract class Middleware |
||
11 | { |
||
12 | /** |
||
13 | * @var Application |
||
14 | */ |
||
15 | protected $application; |
||
16 | /** |
||
17 | * @var Repository |
||
18 | */ |
||
19 | protected $config; |
||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $errorCode = Response::HTTP_FORBIDDEN; |
||
24 | |||
25 | /** |
||
26 | * IpMiddleware constructor. |
||
27 | * |
||
28 | * @param Application $application |
||
29 | * @param Repository $config |
||
30 | */ |
||
31 | public function __construct(Application $application, Repository $config) |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param Request $request |
||
40 | * @return string |
||
41 | */ |
||
42 | protected function realIp($request): string |
||
43 | { |
||
44 | return $request->server('HTTP_CF_CONNECTING_IP') ?? $request->ip(); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Return result if middleware should IP check. |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | protected function shouldCheck(): bool |
||
55 | } |
||
56 | } |
||
57 |