Completed
Pull Request — master (#47)
by Iman
13:15 queued 09:06
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\YouShouldHave;
6
7
class SituationsProxy
8
{
9
    const situations = [
10
        RouteSituations::class,
11
        ViewSituations::class,
12
        EloquentSituations::class,
13
        EventSituations::class,
14
    ];
15
16 103
    public static function call($method, $args)
17
    {
18 103
        $args = is_array($args[0]) ? $args[0] : $args;
19 103
        foreach (self::situations as $className) {
20 103
            if (method_exists($className, $method) || app($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

20
            if (method_exists($className, $method) || app($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...
21 103
                app($className)->$method(...$args);
22
23 103
                return app(YouShouldHave::class);
24
            }
25
        }
26
    }
27
}
28