1 | <?php |
||||
2 | |||||
3 | namespace HayriCan\IpChecker\Http\Middleware; |
||||
4 | |||||
5 | /** |
||||
6 | * Laravel IP Checker |
||||
7 | * |
||||
8 | * @author Hayri Can BARÇIN <hayricanbarcin (#) gmail (.) com> |
||||
9 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||||
10 | * @link https://github.com/HayriCan/laravel-ip-checker |
||||
11 | */ |
||||
12 | |||||
13 | use HayriCan\IpChecker\Contracts\IpCheckerInterface; |
||||
14 | use Closure; |
||||
15 | |||||
16 | class IpChecker |
||||
17 | { |
||||
18 | protected $allowedIps; |
||||
19 | |||||
20 | public function __construct(IpCheckerInterface $ipChecker) |
||||
21 | { |
||||
22 | $this->allowedIps = $ipChecker; |
||||
23 | } |
||||
24 | |||||
25 | /** |
||||
26 | * Handle an incoming request. |
||||
27 | * |
||||
28 | * @param $request |
||||
29 | * @param Closure $next |
||||
30 | * @return \Illuminate\Http\JsonResponse|mixed |
||||
0 ignored issues
–
show
|
|||||
31 | */ |
||||
32 | public function handle($request, Closure $next) |
||||
33 | { |
||||
34 | if (!in_array($request->ip(), $this->allowedIps->getIpArray())) { |
||||
35 | $code = trans('ipchecker::messages.denied_access.code'); |
||||
0 ignored issues
–
show
The function
trans was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
36 | $message = trans('ipchecker::messages.denied_access.message'); |
||||
37 | |||||
38 | if (in_array(config('ipchecker.api_middleware'),$request->route()->gatherMiddleware())){ |
||||
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
39 | $return_array = [ |
||||
40 | 'success'=>false, |
||||
41 | 'code'=>$code, |
||||
42 | 'message'=>$message, |
||||
43 | ]; |
||||
44 | |||||
45 | return response()->json($return_array,200,[],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
||||
0 ignored issues
–
show
The function
response was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | } |
||||
47 | |||||
48 | return response()->view('ipchecker::error',compact('message','code')); |
||||
49 | } |
||||
50 | |||||
51 | return $next($request); |
||||
52 | } |
||||
53 | } |
||||
54 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths