Condition   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 11 2
A always() 0 3 1
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