Passed
Pull Request — stable (#145)
by Nuno
02:33
created

ConsoleException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
dl 0
loc 60
ccs 9
cts 12
cp 0.75
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getExitCode() 0 4 1
A getHeaders() 0 4 1
A setHeaders() 0 6 1
1
<?php
2
3
namespace LaravelZero\Framework\Exceptions;
4
5
use Exception;
6
use LaravelZero\Framework\Contracts\Exceptions\ConsoleException as ConsoleExceptionContract;
7
8
/**
9
 * This is the Laravel Zero Framework Console Exception class.
10
 *
11
 * @author Nuno Maduro <[email protected]>
12
 */
13
class ConsoleException extends Exception implements ConsoleExceptionContract
14
{
15
    /**
16
     * The exit code.
17
     *
18
     * @var int
19
     */
20
    private $exitCode;
21
22
    /**
23
     * The headers.
24
     *
25
     * @var array
26
     */
27
    private $headers;
28
29
    /**
30
     * ConsoleException constructor.
31
     *
32
     * @param int $exitCode
33
     * @param string|null $message
34
     * @param \Exception|null $previous
35
     * @param array $headers
36
     * @param int code
37
     */
38 1
    public function __construct(
39
        int $exitCode, string $message = null, array $headers = [], \Exception $previous = null, ?int $code = 0
40
    ) {
41 1
        $this->exitCode = $exitCode;
42 1
        $this->headers = $headers;
43
44 1
        parent::__construct($message, $code, $previous);
45 1
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function getExitCode(): int
51
    {
52 1
        return $this->exitCode;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 1
    public function getHeaders(): array
59
    {
60 1
        return $this->headers;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function setHeaders(array $headers): ConsoleExceptionContract
67
    {
68
        $this->headers = $headers;
69
70
        return $this;
71
    }
72
}
73