Condition::__call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
ccs 6
cts 6
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
/**
6
 * Class Condition.
7
 *
8
 * @method Otherwise youShouldBeGuest($guard = null)
9
 * @method Otherwise youShouldBeLoggedIn($guard = null)
10
 * @method Otherwise checkAuth($guard = null)
11
 * @method Otherwise yourRequestShouldBeValid($rules, array $messages = [], array $customAttributes = [])
12
 * @method Otherwise validate($rules, array $messages = [], array $customAttributes = [])
13
 * @method Otherwise thisGateShouldAllow($gate, ...$parameters)
14
 * @method Otherwise checkGate($gate, ...$parameters)
15
 * @method Otherwise thisClosureShouldAllow(callable $callback, array $parameters = [])
16
 * @method Otherwise thisValueShouldAllow($value)
17
 * @method Otherwise thisMethodShouldAllow($callback, array $parameters = [])
18
 * @method Otherwise sessionShouldHave($key)
19
 */
20
final class Condition
21
{
22 116
    public function __call(string $method, $args)
23
    {
24 116
        $result = resolve(ConditionsFacade::class)->_call($method, $args);
25
26 116
        if ($result instanceof \Closure) {
27 108
            resolve('heyman.chain')->set('condition', $result);
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

27
            resolve('heyman.chain')->/** @scrutinizer ignore-call */ set('condition', $result);

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...
28
29 108
            return resolve(Otherwise::class);
30
        }
31
32 12
        return $result;
33
    }
34
35 71
    public function always()
36
    {
37 71
        return $this->thisValueShouldAllow(false)->otherwise();
38
    }
39
}
40