GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

functions.inc.php ➔ _e()   C
last analyzed

Complexity

Conditions 12
Paths 204

Size

Total Lines 34

Duplication

Lines 4
Ratio 11.76 %

Code Coverage

Tests 0
CRAP Score 156

Importance

Changes 0
Metric Value
cc 12
nc 204
nop 1
dl 4
loc 34
ccs 0
cts 23
cp 0
crap 156
rs 6.0833
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace vsc;
3
4
use vsc\infrastructure\vsc;
5
6
/**
7
 * Function to turn the triggered errors into exceptions
8
 * @author troelskn at gmail dot com
9
 * @see http://php.net/manual/en/class.errorexception.php
10
 * @param $iSeverity
11
 * @param $sMessage
12
 * @param $sFilename
13
 * @param $iLineNo
14
 * @throws ExceptionError
15
 * @return void
16
 */
17
function exceptions_error_handler($iSeverity, $sMessage, $sFilename, $iLineNo) {
18 1
	if (error_reporting() == 0) {
19
		return;
20
	}
21
22 1
	if (error_reporting() & $iSeverity) {
23 1
		throw new ExceptionError($sMessage, 0, $iSeverity, $sFilename, $iLineNo);
24
	}
25
}
26
27
function getPaths() {
28 1
	return explode(PATH_SEPARATOR, get_include_path());
29
}
30
31
function cleanBuffers($iLevel = null) {
32 1
	$aErrors = array();
33 1
	if (is_null($iLevel)) {
34 1
		$iLevel = ob_get_level();
35
	}
36 1
	for ($i = 0; $i < min(1, $iLevel); $i++) {
37 1
		ob_end_clean();
38
	}
39
40 1
	$iLevel = ob_get_level();
41 1
	for ($i = 0; $i < $iLevel; $i++) {
42
		if (ob_get_length() > 0) {
43
			$s = ob_get_clean();
44
			$aErrors[$i] = $s;
45
		} else {
46
			ob_end_clean();
47
		}
48
	}
49
50 1
	return $aErrors;
51
}
52
53
function getErrorHeaderOutput($e = null) {
54 3
	$sRet = '';
55 3
	if (!vsc::isCli()) {
56 1
		if (!headers_sent()) {
57
			header('HTTP/1.1 500 Internal Server Error');
58
		}
59 1
		$sRet = '<?xml version="1.0" encoding="utf-8"?>';
60 1
		$sRet .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"';
61 1
		$sRet .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
62 1
		$sRet .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">';
63 1
		$sRet .= '<head>';
64 1
		$sRet .= '<style>ul {padding:0; font-size:0.8em} li {padding:0.2em;display:inline} address {position:fixed;bottom:0;}</style>';
65 1
		$sRet .= '<title>Internal Error' . (!($e instanceof \Exception) ? '' : ': ' . substr($e->getMessage(), 0, 20) . '...') . '</title>';
66 1
		$sRet .= '</head>';
67 1
		$sRet .= '<body>';
68 1
		$sRet .= '<strong>Internal Error' . (!($e instanceof \Exception) ? '' : ': ' . $e->getMessage()) . '</strong>';
69 1
		$sRet .= '<address>&copy; VSC</address>';
70 1
		$sRet .= '<ul>';
71 1
		$sRet .= '<li><a href="#" onclick="p = document.getElementById(\'trace\'); if (p.style.display==\'block\') p.style.display=\'none\';else p.style.display=\'block\'; return false">toggle trace</a></li>';
72 1
		if (defined('ROOT_MAIL')) {
73
			$sRet .= '<li><a href="javascript: p = document.getElementById(\'trace\'); document.location.href =\'mailto:' . ROOT_MAIL . '?subject=Problems&amp;body=\' + p.innerHTML; return false">mail me</a></li>';
74
		}
75 1
		$sRet .= '</ul>';
76
77 1 View Code Duplication
		if ($e instanceof \Exception)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78 1
			$sRet .= '<p style="font-size:.8em">Triggered in <strong>' . $e->getFile() . '</strong> at line ' . $e->getLine() . '</p>';
79
80 1
		$sRet .= '<pre style="position:fixed;bottom:2em;display:' . (vsc::getEnv()->isDevelopment() ? 'block' : 'none') . ';font-size:.8em" id="trace">';
81
	}
82
83 3
	return $sRet;
84
}
85
86
/**
87
 * @param \Exception $e
88
 */
89
function _e($e) {
90
	$aErrors = cleanBuffers();
91
	$sRet = '';
92
	if (!vsc::isCli()) {
93
		header('HTTP/1.1 500 Internal Server Error');
94
		echo getErrorHeaderOutput($e);
95
	}
96
97
	if (isDebug()) {
98
		echo ($e instanceof \Exception) ? $e->getTraceAsString() : '';
99
	}
100
101
	if (count($aErrors) > 0) {
102
		if (!vsc::isCli()) { echo '<h2>'; }
103
		echo 'Previous Errors';
104
		if (!vsc::isCli()) { echo '</h2>'; }
105
		if (!vsc::isCli()) { echo '<p>'; }
106
		echo implode($aErrors, vsc::isCli() ? "\n" : '<br/>');
107
		if (!vsc::isCli()) { echo '</p>'; }
108
	}
109
110
	if (!vsc::isCli()) {
111
		echo '</pre>';
112
		echo '</body>';
113
		echo '</html>';
114
	} else {
115 View Code Duplication
		if ($e instanceof \Exception) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
116
			$sRet .= $e->getMessage() . "\n";
117
			$sRet .= "\t" . $e->getFile() . ' at line ' . $e->getLine() . "\n";
118
		}
119
		echo $sRet;
120
	}
121
	exit (0);
122
}
123
124
if (!function_exists('isDebug')) {
125
	function isDebug() {
126 1
		return true;
127
	}
128
}
129