Passed
Pull Request — master (#73)
by Iman
08:53 queued 06:15
created

YouShouldHave::always()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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