Completed
Push — master ( 27f52c...25a546 )
by Iman
08:14
created

Reactions::commit()   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
eloc 1
dl 0
loc 3
ccs 2
cts 2
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\Reactions;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Imanghafoori\HeyMan\Chain;
7
use Imanghafoori\HeyMan\Reactions\Redirect\Redirector;
8
9
final class Reactions
10
{
11 2
    use BeforeReaction;
12
13 2
    public function response(): Responder
14
    {
15
        return new Responder($this);
16 5
    }
17
18 5
    public function redirect(): Redirector
19
    {
20
        return new Redirector($this);
21 2
    }
22
23 2
    public function weThrowNew(string $exception, string $message = '')
24
    {
25 2
        $this->commit(func_get_args(), 'exception');
26
    }
27
28 4
    public function abort($code, string $message = '', array $headers = [])
29
    {
30 4
        $this->commit(func_get_args(), __FUNCTION__);
31 4
    }
32
33 2
    public function weRespondFrom($callback, array $parameters = [])
34
    {
35 2
        $this->commit(func_get_args(), 'respondFrom');
36 2
    }
37
38 1
    public function weDenyAccess(string $message = '')
39
    {
40 1
        $this->commit([AuthorizationException::class, $message], 'exception');
41 1
    }
42
43 81
    public function __destruct()
44
    {
45 81
        resolve(Chain::class)->submitChainConfig();
46 81
    }
47
48 1
    private function commit($args, $methodName)
49
    {
50 1
        resolve(Chain::class)->commitCalledMethod($args, $methodName);
51
    }
52
}
53