Test Setup Failed
Push — master ( dcec01...0415ed )
by Php Easy Api
04:43
created

RoutePolicy::gate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 13
rs 10
1
<?php
2
3
namespace Resta\Router;
4
5
use Resta\Foundation\ApplicationProvider;
6
7
class RoutePolicy extends ApplicationProvider
8
{
9
    /**
10
     * get policy gate
11
     *
12
     * @param callable $callback
13
     * @return mixed|void
14
     */
15
    public function gate(callable $callback)
16
    {
17
        $di = $this->app['di'];
18
19
        if(!method_exists(policy(),Route::getRouteControllerMethod())){
0 ignored issues
show
Bug introduced by
Resta\Router\Route::getRouteControllerMethod() of type http\Exception is incompatible with the type string expected by parameter $method_name of method_exists(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
        if(!method_exists(policy(),/** @scrutinizer ignore-type */ Route::getRouteControllerMethod())){
Loading history...
Bug introduced by
The method getRouteControllerMethod() does not exist on Resta\Router\Route. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        if(!method_exists(policy(),Route::/** @scrutinizer ignore-call */ getRouteControllerMethod())){
Loading history...
20
            $directly = true;
21
        }
22
23
        if(isset($directly) || $di(policy(),Route::getRouteControllerMethod())){
24
            return call_user_func($callback);
25
        }
26
27
        exception()->badMethodCall('policy error');
28
    }
29
}