Completed
Push — master ( 3707ab...b1ac4b )
by Iman
04:03
created

Actions::afterFiringEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
7
class Actions
8
{
9
    /**
10
     * @var \Imanghafoori\HeyMan\Chain
11
     */
12
    private $chain;
13
14
    /**
15
     * Actions constructor.
16
     *
17
     * @param \Imanghafoori\HeyMan\Chain $chain
18
     */
19 58
    public function __construct(Chain $chain)
20
    {
21 58
        $this->chain = $chain;
22 58
    }
23
24 2
    public function response()
25
    {
26 2
        return new Responder($this->chain, $this);
27
    }
28
29 4
    public function redirect()
30
    {
31 4
        return new Redirector($this->chain, $this);
32
    }
33
34 2
    public function afterCalling($callback, array $parameters = [])
35
    {
36 2
        $this->chain->addAfterCall($callback, $parameters);
37
38 2
        return $this;
39
    }
40
41 1
    public function weThrowNew($exception, $message = '')
42
    {
43 1
        $this->chain->addException($exception, $message);
44 1
    }
45
46 1
    public function abort($code, $message = '', array $headers = [])
47
    {
48 1
        $this->chain->addAbort($code, $message, $headers);
49 1
    }
50
51 52
    public function weDenyAccess($message = '')
52
    {
53 52
        $this->chain->addException(AuthorizationException::class, $message);
54 52
    }
55
56 1
    public function afterFiringEvent($event, $payload = [], $halt = false)
57
    {
58 1
        $this->chain->eventFire($event, $payload , $halt);
59
60 1
        return $this;
61
    }
62
63 58
    public function __destruct()
64
    {
65 58
        app(HeyMan::class)->startListening();
66 58
    }
67
}
68