Completed
Push — master ( c5ec2d...1e9b29 )
by Till
03:26
created

CommandFailed::catchException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace TillKruss\LaravelTactician\Events;
4
5
use Illuminate\Queue\SerializesModels;
6
use League\Tactician\CommandEvents\Event\HasCommand;
7
use League\Tactician\CommandEvents\Event\CommandEvent;
8
9
class CommandFailed implements CommandEvent
10
{
11
    use HasCommand, SerializesModels;
12
13
    /**
14
     * The exception instance.
15
     *
16
     * @var Exception|Throwable
17
     */
18
    protected $exception;
19
20
    /**
21
     * Whether the exception is caught, or not.
22
     *
23
     * @var boolean
24
     */
25
    protected $exceptionCaught = false;
26
27
    /**
28
     * Create a new "command failed" event object.
29
     *
30
     * @param object               $command
31
     * @param Exception|Throwable  $exception
32
     */
33
    public function __construct($command, $exception)
34
    {
35
        $this->command = $command;
36
        $this->exception = $exception;
37
    }
38
39
    /**
40
     * Return the exception instance.
41
     *
42
     * @return Exception|Throwable
43
     */
44
    public function getException()
45
    {
46
        return $this->exception;
47
    }
48
49
    /**
50
     * Mark the exception as caught.
51
     */
52
    public function catchException()
53
    {
54
        $this->exceptionCaught = true;
55
    }
56
57
    /**
58
     * Whether the exception is caught, or not.
59
     *
60
     * @return boolean
61
     */
62
    public function isExceptionCaught()
63
    {
64
        return $this->exceptionCaught;
65
    }
66
}
67