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

HeyMan::writeDebugInfo()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 4.125

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 4.125
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Imanghafoori\HeyMan\Switching\Turn;
6
use Imanghafoori\HeyMan\Core\Situations;
7
use Imanghafoori\HeyMan\Conditions\ConditionsFacade;
8
9
class HeyMan
10
{
11
    use Turn;
12
13 14
    public function forget(): Forget
14
    {
15 14
        return new Forget();
16
    }
17
18 109
    public function __call($method, $args)
19
    {
20 109
        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

20
        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...
21
22 109
        $this->writeDebugInfo(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1]);
23
24 109
        return Situations::call($method, $args);
25
    }
26
27 2
    public function checkPoint(string $pointName)
28
    {
29 2
        event('heyman_checkpoint_'.$pointName);
30 1
    }
31
32 2
    public function aliasCondition(string $currentName, string $newName)
33
    {
34 2
        resolve(ConditionsFacade::class)->alias($currentName, $newName);
35 2
    }
36
37 1
    public function defineCondition(string $name, $callable)
38
    {
39 1
        resolve(ConditionsFacade::class)->define($name, $callable);
40 1
    }
41
42 1
    public function condition(string $name, $callable)
43
    {
44 1
        $this->defineCondition($name, $callable);
45 1
    }
46
47
    /**
48
     * @param $debugTrace
49
     */
50 109
    private function writeDebugInfo($debugTrace)
51
    {
52 109
        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

52
        if (config('app.debug') && ! app()->/** @scrutinizer ignore-call */ environment('production')) {
Loading history...
53
            $info = array_only($debugTrace, ['file', 'line', 'args']);
54
            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

54
            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...
55
        }
56 109
    }
57
}
58