Passed
Push — master ( 4e3c19...6e35e1 )
by Fabio
06:44 queued 01:59
created

TExitException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getExitCode() 0 3 1
A __construct() 0 4 1
1
<?php
2
/**
3
 * TExitException file
4
 *
5
 * @author Brad Anderson <[email protected]>
6
 * @link https://github.com/pradosoft/prado
7
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
8
 */
9
10
namespace Prado\Exceptions;
11
12
/**
13
 * TExitException class
14
 *
15
 * Throwing TExitException will interrupt the application and gracefully terminate.
16
 * The application will exit with the specified {@link getExitCode Exit Code}.
17
 *
18
 * This exception is not designed to be caught by any class other than TApplication.
19
 * If this exception is caught, it may interfere with the graceful termination of
20
 * the application.
21
 *
22
 * @author Brad Anderson <[email protected]>
23
 * @since 4.2.3
24
 */
25
class TExitException extends TSystemException
26
{
27
	/**
28
	 * @var int The exit code
29
	 */
30
	protected int $_exitCode;
31
32
	/**
33
	 * Constructor.
34
	 * @param int $exitCode The status exit code.
35
	 * @param ?string $message The error message.
36
	 * @param array $args All the additional parameters.
37
	 */
38
	public function __construct(int $exitCode = 0, ?string $message = null, ...$args)
39
	{
40
		$this->_exitCode = $exitCode;
41
		parent::__construct($message, ...$args);
42
	}
43
44
	/**
45
	 * @return int The exit code to end the application process.
46
	 */
47
	public function getExitCode(): int
48
	{
49
		return $this->_exitCode;
50
	}
51
}
52