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

Actions   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

9 Methods

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