Passed
Push — master ( e9b436...3e0c4b )
by Iman
14:26 queued 10:55
created

SituationsProxy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 11
dl 0
loc 17
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A call() 0 8 5
1
<?php
2
3
namespace Imanghafoori\HeyMan\Situations;
4
5
use Imanghafoori\HeyMan\WatchingStrategies\EloquentModels\EloquentSituations;
6
use Imanghafoori\HeyMan\WatchingStrategies\Routes\RouteSituations;
7
use Imanghafoori\HeyMan\WatchingStrategies\Views\ViewSituations;
8
use Imanghafoori\HeyMan\YouShouldHave;
9
10
final class SituationsProxy
11
{
12
    const situations = [
13
        RouteSituations::class,
14
        EloquentSituations::class,
15
        ViewSituations::class,
16
        EventSituations::class,
17
    ];
18
19 105
    public static function call($method, $args)
20
    {
21 105
        $args = is_array($args[0]) ? $args[0] : $args;
22 105
        foreach (self::situations as $className) {
23 105
            if (method_exists($className, $method) || resolve($className)->hasMethod($method)) {
0 ignored issues
show
Bug introduced by
The method hasMethod() does not exist on Illuminate\Foundation\Application. Did you maybe mean hasMethodBinding()? ( Ignorable by Annotation )

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

23
            if (method_exists($className, $method) || resolve($className)->/** @scrutinizer ignore-call */ hasMethod($method)) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
24 105
                resolve($className)->$method(...$args);
25
26 105
                return resolve(YouShouldHave::class);
27
            }
28
        }
29
    }
30
}
31