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

Reactions   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
eloc 10
dl 0
loc 42
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A weDenyAccess() 0 3 1
A abort() 0 3 1
A weThrowNew() 0 3 1
A commit() 0 3 1
A response() 0 3 1
A weRespondFrom() 0 3 1
A __destruct() 0 3 1
A redirect() 0 3 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