Completed
Push — master ( fa7559...762c49 )
by Iman
03:40
created

Reactions   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
eloc 12
dl 0
loc 49
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A weDenyAccess() 0 3 1
A abort() 0 3 1
A weThrowNew() 0 3 1
A response() 0 3 1
A afterFiringEvent() 0 5 1
A weRespondFrom() 0 3 1
A __destruct() 0 3 1
A redirect() 0 3 1
A afterCalling() 0 5 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Reactions;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Imanghafoori\HeyMan\Chain;
7
8
final class Reactions
9
{
10 2
    public function response(): Responder
11
    {
12 2
        return new Responder($this);
13
    }
14
15 5
    public function redirect(): Redirector
16
    {
17 5
        return new Redirector($this);
18
    }
19
20 2
    public function afterCalling($callback, array $parameters = []): self
21
    {
22 2
        resolve(Chain::class)->addAfterCall($callback, $parameters);
23
24 2
        return $this;
25
    }
26
27 4
    public function weThrowNew(string $exception, string $message = '')
28
    {
29 4
        resolve(Chain::class)->commit(func_get_args(), 'exception');
30 4
    }
31
32 2
    public function abort($code, string $message = '', array $headers = [])
33
    {
34 2
        resolve(Chain::class)->commit(func_get_args(), __FUNCTION__);
35 2
    }
36
37 1
    public function weRespondFrom($callback, array $parameters = [])
38
    {
39 1
        resolve(Chain::class)->commit(func_get_args(), 'respondFrom');
40 1
    }
41
42 81
    public function weDenyAccess(string $message = '')
43
    {
44 81
        resolve(Chain::class)->commit([AuthorizationException::class, $message], 'exception');
45 81
    }
46
47 1
    public function afterFiringEvent($event, $payload = [], $halt = false): self
48
    {
49 1
        resolve(Chain::class)->eventFire($event, $payload, $halt);
50
51 1
        return $this;
52
    }
53
54 91
    public function __destruct()
55
    {
56 91
        resolve(Chain::class)->submitChainConfig();
57 91
    }
58
}
59