HeyMan::__call()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 3
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Illuminate\Support\Arr;
6
use Imanghafoori\HeyMan\Core\ConditionsFacade;
7
use Imanghafoori\HeyMan\Core\Forget;
8
use Imanghafoori\HeyMan\Core\Reaction;
9
use Imanghafoori\HeyMan\Core\Situations;
10
use Imanghafoori\HeyMan\Switching\Turn;
11
12
class HeyMan
13
{
14
    use Turn;
15
16 14
    public function forget()
17
    {
18 14
        return new Forget();
19
    }
20
21 117
    public function __call($method, $args)
22
    {
23 117
        resolve('heyman.chain')->startChain();
0 ignored issues
show
Bug introduced by
The method startChain() 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.chain')->/** @scrutinizer ignore-call */ startChain();

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
25 117
        $this->writeDebugInfo(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1]);
26
27 117
        return Situations::call($method, $args);
28
    }
29
30 2
    public function checkPoint(string $pointName)
31
    {
32 2
        event('heyman_checkpoint_'.$pointName);
33 1
    }
34
35 2
    public function aliasCondition(string $currentName, string $newName)
36
    {
37 2
        resolve(ConditionsFacade::class)->alias($currentName, $newName);
38 2
    }
39
40 121
    public function aliasSituation(string $currentName, string $newName)
41
    {
42 121
        Situations::aliasMethod($currentName, $newName);
43 121
    }
44
45 2
    public function aliasReaction(string $currentName, string $newName)
46
    {
47 2
        resolve(Reaction::class)->alias($currentName, $newName);
48 2
    }
49
50
    public function defineReaction($methodName, $callable)
51
    {
52
        resolve(Reaction::class)->define($methodName, $callable);
53
    }
54
55 1
    public function defineCondition($methodName, $callable)
56
    {
57 1
        resolve(ConditionsFacade::class)->define($methodName, $callable);
58 1
    }
59
60 1
    public function condition($methodName, $callable)
61
    {
62 1
        $this->defineCondition($methodName, $callable);
63 1
    }
64
65 117
    private function writeDebugInfo($debugTrace)
66
    {
67 117
        if (config('app.debug') && ! app()->environment('production')) {
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

67
        if (config('app.debug') && ! app()->/** @scrutinizer ignore-call */ environment('production')) {
Loading history...
68
            $info = Arr::only($debugTrace, ['file', 'line', 'args']);
69
            resolve('heyman.chain')->set('debugInfo', $info);
0 ignored issues
show
Bug introduced by
The method set() 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

69
            resolve('heyman.chain')->/** @scrutinizer ignore-call */ set('debugInfo', $info);

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...
70
        }
71 117
    }
72
}
73