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

ConsoleException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 5
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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