Passed
Push — master ( 584580...d92373 )
by Iman
06:42
created

HeyMan::condition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

21
        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...
22 105
23
        if (config()->get('app.debug') and !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

23
        if (config()->get('app.debug') and !app()->/** @scrutinizer ignore-call */ environment('production')) {
Loading history...
24
            $info = array_only(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1], ['file', 'line', 'args']);
25
            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

25
            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...
26
        }
27 105
28
        return  SituationsProxy::call($method, $args);
29
    }
30 38
31
    public function makeSure($app): HttpClient
32 38
    {
33
        return new HttpClient($app);
34
    }
35 2
36
    public function checkPoint(string $pointName)
37 2
    {
38 1
        event('heyman_checkpoint_'.$pointName);
39
    }
40
41
    public function condition(string $name, $callable)
42
    {
43
        app(ConditionsFacade::class)->define($name, $callable);
44
    }
45
}
46