Conditions | 17 |
Paths | 768 |
Total Lines | 154 |
Code Lines | 67 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
35 | public static function renderException($message, $string, $code, $file, $line, $trace) |
||
36 | { |
||
37 | ob_start(); |
||
38 | |||
39 | /* |
||
40 | * @todo add backlink to the exception codes list |
||
41 | */ |
||
42 | if ($code > 0) { |
||
43 | $code = '(#' . $code . ')'; |
||
44 | } else { |
||
45 | $code = ''; |
||
46 | } |
||
47 | |||
48 | // Header |
||
49 | $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'; |
||
50 | $html .= ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; |
||
51 | $html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'; |
||
52 | $html .= '<head>'; |
||
53 | $html .= '<title>Koch Framework Exception ' . $code . ' - ' . $message . '</title>'; |
||
54 | $html .= '<link rel="stylesheet" href="' . WWW_ROOT_THEMES_CORE . 'css/error.css" type="text/css" />'; |
||
55 | $html .= '</head>'; |
||
56 | |||
57 | // Body |
||
58 | $html .= '<body>'; |
||
59 | |||
60 | // Fieldset |
||
61 | $html .= '<fieldset id="top" class="error_yellow">'; |
||
62 | |||
63 | // Errorlogo |
||
64 | $html .= '<div style="float: left; margin: 5px; margin-right: 25px; padding: 20px;">'; |
||
65 | $html .= '<img src="' . WWW_ROOT_THEMES_CORE . 'images/Clansuite-Toolbar-Icon-64-exception.png" '; |
||
66 | $html .= 'style="border: 2px groove #000000;" alt="Clansuite Exception Icon" /></div>'; |
||
67 | |||
68 | // Fieldset Legend |
||
69 | $html .= '<legend>Koch Framework Exception</legend>'; |
||
70 | |||
71 | // Exception Table |
||
72 | $html .= '<table width="80%"><tr><td>'; |
||
73 | |||
74 | /* |
||
75 | * Panel 1 |
||
76 | * |
||
77 | * Exception Message and File |
||
78 | */ |
||
79 | |||
80 | $html .= '<div id="panel1" class="panel">'; |
||
81 | $html .= '<h3>Exception ' . $code . '</h3><h4>' . $message . '</h4>'; |
||
82 | $html .= '<strong>' . Errorhandler::getFileLink($file, $line) . '.</strong>'; |
||
83 | $html .= '</div>'; |
||
84 | |||
85 | /* |
||
86 | * Panel 2 |
||
87 | * |
||
88 | * Debug Backtrace |
||
89 | */ |
||
90 | if (defined('DEBUG') and DEBUG === 1) { |
||
91 | // lets get the backtrace as html table |
||
92 | $html .= Errorhandler::getDebugBacktrace($trace); |
||
93 | } |
||
94 | |||
95 | /* |
||
96 | * Panel 3 |
||
97 | * |
||
98 | * Server Environment Informations |
||
99 | */ |
||
100 | if (defined('DEBUG') and DEBUG === 1) { |
||
101 | $html .= '<div id="panel3" class="panel">'; |
||
102 | $html .= '<h3>Server Environment</h3>'; |
||
103 | $html .= '<table width="95%">'; |
||
104 | $html .= '<tr><td><strong>Date: </strong></td><td>' . date('r') . '</td></tr>'; |
||
105 | $html .= '<tr><td><strong>Remote: </strong></td><td>' . $_SERVER['REMOTE_ADDR'] . '</td></tr>'; |
||
106 | $html .= '<tr><td><strong>Request: </strong></td><td>index.php?' . $_SERVER['QUERY_STRING'] . '</td></tr>'; |
||
107 | $html .= '<tr><td><strong>PHP: </strong></td><td>' . PHP_VERSION . ' ' . PHP_EXTRA_VERSION . '</td></tr>'; |
||
108 | $html .= '<tr><td><strong>Server: </strong></td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>'; |
||
109 | $html .= '<tr><td><strong>Agent: </strong></td><td>' . $_SERVER['HTTP_USER_AGENT'] . '</td></tr>'; |
||
110 | $html .= '<tr><td><strong>Application: </strong></td>'; |
||
111 | $html .= '<td>' . APPLICATION_VERSION . ' ' . APPLICATION_VERSION_STATE; |
||
112 | $html .= ' (' . APPLICATION_VERSION_NAME . ')</td></tr>'; |
||
113 | $html .= '</table></div>'; |
||
114 | } |
||
115 | |||
116 | /* |
||
117 | * Panel 4 |
||
118 | * |
||
119 | * Additional Information |
||
120 | */ |
||
121 | if (empty(self::$exception_template) === false) { |
||
122 | $html .= '<div id="panel4" class="panel">'; |
||
123 | $html .= '<h3>Additional Information & Solution Suggestion</h3>'; |
||
124 | $html .= self::$exception_template . '</div>'; |
||
125 | } |
||
126 | |||
127 | /* |
||
128 | * Panel 5 |
||
129 | * |
||
130 | * Rapid Development |
||
131 | */ |
||
132 | $placeholders = []; |
||
133 | // assign placeholders for replacements in the html |
||
134 | if (strpos($message, 'action_')) { |
||
135 | $placeholders['actionname'] = substr($message, strpos($message, 'action_')); |
||
136 | } elseif (strpos($message, 'module_')) { |
||
137 | $placeholders['classname'] = substr($message, strpos($message, 'module_')); |
||
138 | } |
||
139 | |||
140 | if (empty($_GET['mod']) === false) { |
||
141 | $placeholders['modulename'] = (string) stripslashes($_GET['mod']); |
||
142 | } else { |
||
143 | $placeholders['modulename'] = ''; |
||
144 | } |
||
145 | |||
146 | // add development helper template to exceptions |
||
147 | if (defined('DEVELOPMENT') and DEVELOPMENT === 1 and defined('RAPIDDEVTPL') and RAPIDDEVTPL === 1) { |
||
148 | $html .= '<div id="panel5" class="panel">'; |
||
149 | $html .= '<h3>Rapid Application Development</h3>'; |
||
150 | $html .= Exception::getExceptionDevelopmentTemplate($placeholders) . '</div>'; |
||
151 | } |
||
152 | |||
153 | /* |
||
154 | * Panel 6 |
||
155 | * |
||
156 | * Backlink to Bugtracker with Exceptionmessage |
||
157 | * @link http://trac.clansuite.com/newticket |
||
158 | */ |
||
159 | $html .= Errorhandler::getBugtrackerBacklinks($message, $file, $line, $trace); |
||
160 | |||
161 | // close all html element table |
||
162 | $html .= '</table>'; |
||
163 | |||
164 | /* |
||
165 | * Panel 7 |
||
166 | * |
||
167 | * Footer with Support-Backlinks |
||
168 | */ |
||
169 | $html .= Errorhandler::getSupportBacklinks($this); |
||
170 | |||
171 | // close all html elements: fieldset, body+page |
||
172 | $html .= '</fieldset>'; |
||
173 | $html .= '</body></html>'; |
||
174 | |||
175 | // save session before exit - but only if this is not a pdo exception |
||
176 | // that would trigger a fatal error, when trying to write to the db during session save |
||
177 | if ((bool) session_id() and false === strpos($message, 'SQLSTATE')) { |
||
178 | session_write_close(); |
||
179 | } |
||
180 | |||
181 | // clear all output buffers |
||
182 | if (ob_get_length()) { |
||
183 | ob_end_clean(); |
||
184 | } |
||
185 | |||
186 | // Output the errormessage |
||
187 | return $html; |
||
188 | } |
||
189 | |||
279 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.