Passed
Push — master ( 99eb02...369f6b )
by Iman
02:44
created

Situations::methodExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Imanghafoori\HeyMan\Core;
4
5
use Imanghafoori\HeyMan\YouShouldHave;
6
7
final class Situations
8
{
9
    private static $methods = [];
10
11 113
    public static function add($listenerClass, $situation, $methods): void
12
    {
13 113
        foreach ($methods as $method) {
14 113
            self::$methods[$method] = [$listenerClass, $situation];
15
        }
16 113
    }
17
18 109
    public static function call($method, $args)
19
    {
20 109
        $args = is_array($args[0]) ? $args[0] : $args;
21 109
        [$listenerClass, $situation] = self::$methods[$method];
22
23 109
        resolve('heyman.chains')->init(
0 ignored issues
show
Bug introduced by
The method init() does not exist on Illuminate\Foundation\Application. ( Ignorable by Annotation )

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

23
        resolve('heyman.chains')->/** @scrutinizer ignore-call */ init(

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 109
            $listenerClass, ...resolve($situation)->normalize($method, $args)
0 ignored issues
show
Bug introduced by
The method normalize() does not exist on Illuminate\Foundation\Application. ( Ignorable by Annotation )

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

24
            $listenerClass, ...resolve($situation)->/** @scrutinizer ignore-call */ normalize($method, $args)

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...
25
        );
26
27 108
        return resolve(YouShouldHave::class);
28
    }
29
}
30