Completed
Push — master ( 997ad8...27f0d0 )
by Iman
03:08
created

Actions::abort()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
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
    public $response = [];
10
11
    public $redirect = [];
12
13
    public $exception;
14
15 2
    public function response()
16
    {
17 2
        return new Responder($this);
18
    }
19
20 3
    public function redirect()
21
    {
22 3
        return new Redirector($this);
23
    }
24
25 1
    public function afterCalling($callback, array $parameters = [])
26
    {
27 1
        app()->call($callback, $parameters);
28
29 1
        return $this;
30
    }
31
32 1
    public function weThrowNew($exception, $message = '')
33
    {
34 1
        $this->exception = new $exception($message);
35 1
    }
36
37 1
    public function abort($code, $message = '', array $headers = [])
38
    {
39
        try {
40 1
            abort($code, $message, $headers);
41 1
        } catch (\Exception $e) {
42 1
            $this->exception = $e;
43
        }
44 1
    }
45
46 51
    public function weDenyAccess($msg = '')
47
    {
48 51
        $this->exception = new AuthorizationException($msg);
49 51
    }
50
51
52
    public function afterFiringEvent(...$args)
53
    {
54
        app('events')->dispatch(...$args);
0 ignored issues
show
Bug introduced by
$args is expanded, but the parameter $event of Illuminate\Events\Dispatcher::dispatch() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

54
        app('events')->dispatch(/** @scrutinizer ignore-type */ ...$args);
Loading history...
55
56
        return $this;
57
    }
58
59 56
    public function __destruct()
60
    {
61 56
        app(HeyMan::class)->startListening($this->response, $this->exception, $this->redirect);
62 56
    }
63
64
}