Passed
Push — master ( c61266...84ac3f )
by Iman
11:29 queued 08:42
created

YouShouldHave   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 5 1
A always() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Imanghafoori\HeyMan\Conditions\ConditionsFacade;
6
use Imanghafoori\HeyMan\Conditions\RequestValidation;
7
use Imanghafoori\HeyMan\Reactions\Reactions;
8
9
/**
10
 * Class YouShouldHave.
11
 *
12
 * @method Otherwise youShouldBeGuest($guard = null)
13
 * @method Otherwise youShouldBeLoggedIn($guard = null)
14
 * @method Otherwise thisGateShouldAllow($gate, ...$parameters)
15
 * @method Otherwise youShouldHaveRole(string $role)
16
 * @method Otherwise thisClosureShouldAllow(callable $callback, array $parameters = [])
17
 * @method Otherwise thisValueShouldAllow($value)
18
 * @method Otherwise thisMethodShouldAllow($callback, array $parameters = [])
19
 * @method Otherwise sessionShouldHave($key)
20
 */
21
final class YouShouldHave
22
{
23
    use RequestValidation;
24
25 99
    public function __call($method, $args): Otherwise
26
    {
27 99
        resolve(ChainManager::class)->set('condition', app(ConditionsFacade::class)->$method(...$args));
28
29 99
        return resolve(Otherwise::class);
30
    }
31
32 71
    public function always() : Reactions
33
    {
34 71
        return $this->thisValueShouldAllow(false)->otherwise();
35
    }
36
}
37