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

YouShouldHave::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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