CommandFailed   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 56
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2
ccs 12
cts 12
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getException() 0 4 1
A catchException() 0 4 1
A isExceptionCaught() 0 4 1
1
<?php
2
3
namespace League\Tactician\CommandEvents\Event;
4
5
use League\Event\Event;
6
7
/**
8
 * Emitted when a command is failed
9
 */
10
final class CommandFailed extends Event implements CommandEvent
11
{
12
    use HasCommand;
13
14
    /**
15
     * @var \Exception
16
     */
17
    protected $exception;
18
19
    /**
20
     * Checks whether exception is caught
21
     *
22
     * @var bool
23
     */
24
    protected $exceptionCaught = false;
25
26
    /**
27
     * @param object     $command
28
     * @param \Exception $exception
29
     */
30 9
    public function __construct($command, \Exception $exception)
31
    {
32 9
        $this->command = $command;
33 9
        $this->exception = $exception;
34
35 9
        parent::__construct('command.failed');
36 9
    }
37
38
    /**
39
     * Returns the exception
40
     *
41
     * @return \Exception
42
     */
43 1
    public function getException()
44
    {
45 1
        return $this->exception;
46
    }
47
48
    /**
49
     * Indicates that exception is caught
50
     */
51 2
    public function catchException()
52
    {
53 2
        $this->exceptionCaught = true;
54 2
    }
55
56
    /**
57
     * Checks whether exception is caught
58
     *
59
     * @return bool
60
     */
61 3
    public function isExceptionCaught()
62
    {
63 3
        return $this->exceptionCaught;
64
    }
65
}
66