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

Reactions::__construct()   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 1
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\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