Completed
Push — master ( ddac6b...cf6d46 )
by Kenji
03:11
created

exit__.php ➔ exit__()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 3
eloc 18
nc 4
nop 1
dl 0
loc 27
rs 8.8571
1
<?php
2
/**
3
 * Part of ci-phpunit-test
4
 *
5
 * @author     Kenji Suzuki <https://github.com/kenjis>
6
 * @license    MIT License
7
 * @copyright  2015 Kenji Suzuki
8
 * @link       https://github.com/kenjis/ci-phpunit-test
9
 */
10
11
function exit__($status = null)
12
{
13
	$trace = debug_backtrace();
14
	$file = $trace[0]['file'];
15
	$line = $trace[0]['line'];
16
	$class = isset($trace[1]['class']) ? $trace[1]['class'] : null;
17
	$method = $trace[1]['function'];
18
19
	if ($class === null)
20
	{
21
		$message = 'exit() called in ' . $method . '() function';
22
	}
23
	else
24
	{
25
		$message = 'exit() called in ' . $class . '::' . $method . '()';
26
	}
27
28
	$exception_name = Kenjis\MonkeyPatch\MonkeyPatchManager::getExitExceptionClassname();
29
	$exception = new $exception_name($message);
30
	$exception->file = $file;
31
	$exception->line = $line;
32
	$exception->class = $class;
33
	$exception->method = $method;
34
	$exception->exit_status = $status;
35
36
	throw $exception;
37
}
38