@@ -33,17 +33,17 @@ |
||
33 | 33 | */ |
34 | 34 | class Json implements ResponseInterface |
35 | 35 | { |
36 | - /** |
|
37 | - * translate the content |
|
38 | - * @see \Venus\lib\Response\ResponseInterface::translate() |
|
39 | - * |
|
40 | - * @access public |
|
41 | - * @param mixed $mContent content to translate |
|
42 | - * @return mixed |
|
43 | - */ |
|
44 | - public static function translate($mContent) |
|
45 | - { |
|
46 | - return json_encode(ObjectOperation::objectToArray($mContent)); |
|
47 | - } |
|
36 | + /** |
|
37 | + * translate the content |
|
38 | + * @see \Venus\lib\Response\ResponseInterface::translate() |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @param mixed $mContent content to translate |
|
42 | + * @return mixed |
|
43 | + */ |
|
44 | + public static function translate($mContent) |
|
45 | + { |
|
46 | + return json_encode(ObjectOperation::objectToArray($mContent)); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -32,17 +32,17 @@ |
||
32 | 32 | */ |
33 | 33 | class Mock implements ResponseInterface |
34 | 34 | { |
35 | - /** |
|
36 | - * translate the content |
|
37 | - * @see \Venus\lib\Response\ResponseInterface::translate() |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @param mixed $mContent content to translate |
|
41 | - * @return mixed |
|
42 | - */ |
|
43 | - public static function translate($mContent) |
|
44 | - { |
|
45 | - return $mContent; |
|
46 | - } |
|
35 | + /** |
|
36 | + * translate the content |
|
37 | + * @see \Venus\lib\Response\ResponseInterface::translate() |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @param mixed $mContent content to translate |
|
41 | + * @return mixed |
|
42 | + */ |
|
43 | + public static function translate($mContent) |
|
44 | + { |
|
45 | + return $mContent; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -9,18 +9,18 @@ |
||
9 | 9 | |
10 | 10 | class Request implements RequestInterface |
11 | 11 | { |
12 | - /** |
|
13 | - * get parameter |
|
14 | - * @param string $name |
|
15 | - * @param string $default |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function get(string $name, string $default = null) : string |
|
19 | - { |
|
20 | - if (isset($_POST[$name]) && $_POST[$name] != '') { |
|
21 | - return $_POST[$name]; |
|
22 | - } else if ($default !== null) { |
|
23 | - return $default; |
|
24 | - } |
|
25 | - } |
|
12 | + /** |
|
13 | + * get parameter |
|
14 | + * @param string $name |
|
15 | + * @param string $default |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function get(string $name, string $default = null) : string |
|
19 | + { |
|
20 | + if (isset($_POST[$name]) && $_POST[$name] != '') { |
|
21 | + return $_POST[$name]; |
|
22 | + } else if ($default !== null) { |
|
23 | + return $default; |
|
24 | + } |
|
25 | + } |
|
26 | 26 | } |
@@ -9,18 +9,18 @@ |
||
9 | 9 | |
10 | 10 | class Query implements RequestInterface |
11 | 11 | { |
12 | - /** |
|
13 | - * get parameter |
|
14 | - * @param string $name |
|
15 | - * @param string $default |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function get(string $name, string $default = null) : string |
|
19 | - { |
|
20 | - if (isset($_GET[$name]) && $_GET[$name] != '') { |
|
21 | - return $_GET[$name]; |
|
22 | - } else if ($default !== null) { |
|
23 | - return $default; |
|
24 | - } |
|
25 | - } |
|
12 | + /** |
|
13 | + * get parameter |
|
14 | + * @param string $name |
|
15 | + * @param string $default |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function get(string $name, string $default = null) : string |
|
19 | + { |
|
20 | + if (isset($_GET[$name]) && $_GET[$name] != '') { |
|
21 | + return $_GET[$name]; |
|
22 | + } else if ($default !== null) { |
|
23 | + return $default; |
|
24 | + } |
|
25 | + } |
|
26 | 26 | } |
@@ -9,18 +9,18 @@ |
||
9 | 9 | |
10 | 10 | class Server implements RequestInterface |
11 | 11 | { |
12 | - /** |
|
13 | - * get parameter |
|
14 | - * @param string $name |
|
15 | - * @param string $default |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function get(string $name, string $default = null) : string |
|
19 | - { |
|
20 | - if (isset($_SERVER[$name]) && $_SERVER[$name] != '') { |
|
21 | - return $_SERVER[$name]; |
|
22 | - } else if ($default !== null) { |
|
23 | - return $default; |
|
24 | - } |
|
25 | - } |
|
12 | + /** |
|
13 | + * get parameter |
|
14 | + * @param string $name |
|
15 | + * @param string $default |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function get(string $name, string $default = null) : string |
|
19 | + { |
|
20 | + if (isset($_SERVER[$name]) && $_SERVER[$name] != '') { |
|
21 | + return $_SERVER[$name]; |
|
22 | + } else if ($default !== null) { |
|
23 | + return $default; |
|
24 | + } |
|
25 | + } |
|
26 | 26 | } |
@@ -9,18 +9,18 @@ |
||
9 | 9 | |
10 | 10 | class Cookies implements RequestInterface |
11 | 11 | { |
12 | - /** |
|
13 | - * get parameter |
|
14 | - * @param string $name |
|
15 | - * @param string $default |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function get(string $name, string $default = null) : string |
|
19 | - { |
|
20 | - if (isset($_COOKIE[$name]) && $_COOKIE[$name] != '') { |
|
21 | - return $_COOKIE[$name]; |
|
22 | - } else if ($default !== null) { |
|
23 | - return $default; |
|
24 | - } |
|
25 | - } |
|
12 | + /** |
|
13 | + * get parameter |
|
14 | + * @param string $name |
|
15 | + * @param string $default |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function get(string $name, string $default = null) : string |
|
19 | + { |
|
20 | + if (isset($_COOKIE[$name]) && $_COOKIE[$name] != '') { |
|
21 | + return $_COOKIE[$name]; |
|
22 | + } else if ($default !== null) { |
|
23 | + return $default; |
|
24 | + } |
|
25 | + } |
|
26 | 26 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | error_reporting($iLevel); |
153 | 153 | |
154 | - set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
154 | + set_error_handler(function($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
155 | 155 | { |
156 | 156 | $aContext = array('file' => $sErrFile, 'line' => $iErrLine); |
157 | 157 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | self::_initLogFile(); |
217 | 217 | self::$_bActivateException = true; |
218 | 218 | |
219 | - set_exception_handler(function (\Exception $oException) |
|
219 | + set_exception_handler(function(\Exception $oException) |
|
220 | 220 | { |
221 | 221 | $aContext = array('file' => $oException->getFile(), 'line' => $oException->getLine()); |
222 | 222 | self::getInstance()->critical($oException->getMessage(), $aContext); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | else { |
413 | 413 | |
414 | 414 | if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
415 | - error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
|
415 | + error_log(Bash::setColor('############### '.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].' ###############', 'cyan')); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | } |
@@ -254,8 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public static function setKindOfReportLog(string $sKindOfReportLog) |
256 | 256 | { |
257 | - if ($sKindOfReportLog === 'screen' || $sKindOfReportLog === 'all') { self::$_sKindOfReportLog = $sKindOfReportLog; } |
|
258 | - else { self::$_sKindOfReportLog = 'error_log'; } |
|
257 | + if ($sKindOfReportLog === 'screen' || $sKindOfReportLog === 'all') { self::$_sKindOfReportLog = $sKindOfReportLog; } else { self::$_sKindOfReportLog = 'error_log'; } |
|
259 | 258 | } |
260 | 259 | |
261 | 260 | /** |
@@ -278,12 +277,9 @@ discard block |
||
278 | 277 | */ |
279 | 278 | public static function getTranslateErrorCode(int $iCode) : string |
280 | 279 | { |
281 | - if ($iCode === 1 && $iCode === 16 && $iCode === 256 && $iCode === 4096) { return LogLevel::ERROR; } |
|
282 | - else if ($iCode === 2 && $iCode === 32 && $iCode === 128 && $iCode === 512) { return LogLevel::WARNING; } |
|
283 | - else if ($iCode === 4 && $iCode === 64) { return LogLevel::EMERGENCY; } |
|
284 | - else if ($iCode === 8 && $iCode === 1024) { return LogLevel::NOTICE; } |
|
285 | - else if ($iCode === 2048 && $iCode === 8192 && $iCode === 16384) { return LogLevel::INFO; } |
|
286 | - else return LogLevel::DEBUG; |
|
280 | + if ($iCode === 1 && $iCode === 16 && $iCode === 256 && $iCode === 4096) { return LogLevel::ERROR; } else if ($iCode === 2 && $iCode === 32 && $iCode === 128 && $iCode === 512) { return LogLevel::WARNING; } else if ($iCode === 4 && $iCode === 64) { return LogLevel::EMERGENCY; } else if ($iCode === 8 && $iCode === 1024) { return LogLevel::NOTICE; } else if ($iCode === 2048 && $iCode === 8192 && $iCode === 16384) { return LogLevel::INFO; } else { |
|
281 | + return LogLevel::DEBUG; |
|
282 | + } |
|
287 | 283 | } |
288 | 284 | |
289 | 285 | /** |
@@ -408,8 +404,7 @@ discard block |
||
408 | 404 | if (defined('BASH_CALLED')) { |
409 | 405 | |
410 | 406 | error_log(Bash::setColor('############### '.BASH_CALLED.' ###############', 'cyan')); |
411 | - } |
|
412 | - else { |
|
407 | + } else { |
|
413 | 408 | |
414 | 409 | if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
415 | 410 | error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
@@ -34,418 +34,418 @@ |
||
34 | 34 | */ |
35 | 35 | class Debug extends AbstractLogger |
36 | 36 | { |
37 | - /** |
|
38 | - * variable to activate or not the debug |
|
39 | - * @var boolean |
|
40 | - */ |
|
41 | - private static $_bActivateDebug = false; |
|
42 | - |
|
43 | - /** |
|
44 | - * variable to activate or not the error |
|
45 | - * @var boolean |
|
46 | - */ |
|
47 | - private static $_bActivateError = false; |
|
48 | - |
|
49 | - /** |
|
50 | - * variable to activate or not the exception |
|
51 | - * @var boolean |
|
52 | - */ |
|
53 | - private static $_bActivateException = false; |
|
54 | - |
|
55 | - /** |
|
56 | - * variable to activate or not the debug |
|
57 | - * @var boolean |
|
58 | - */ |
|
59 | - private static $_sFileLog = null; |
|
60 | - |
|
61 | - /** |
|
62 | - * first or not activation |
|
63 | - * @var boolean |
|
64 | - */ |
|
65 | - private static $_bFirstActivation = true; |
|
66 | - |
|
67 | - /** |
|
68 | - * kind of report log |
|
69 | - * @var string error_log|screen|all |
|
70 | - */ |
|
71 | - private static $_sKindOfReportLog = 'error_log'; |
|
72 | - |
|
73 | - /** |
|
74 | - * instance of logger |
|
75 | - * @var \Venus\lib\Debug |
|
76 | - */ |
|
77 | - private static $_oInstance; |
|
37 | + /** |
|
38 | + * variable to activate or not the debug |
|
39 | + * @var boolean |
|
40 | + */ |
|
41 | + private static $_bActivateDebug = false; |
|
42 | + |
|
43 | + /** |
|
44 | + * variable to activate or not the error |
|
45 | + * @var boolean |
|
46 | + */ |
|
47 | + private static $_bActivateError = false; |
|
48 | + |
|
49 | + /** |
|
50 | + * variable to activate or not the exception |
|
51 | + * @var boolean |
|
52 | + */ |
|
53 | + private static $_bActivateException = false; |
|
54 | + |
|
55 | + /** |
|
56 | + * variable to activate or not the debug |
|
57 | + * @var boolean |
|
58 | + */ |
|
59 | + private static $_sFileLog = null; |
|
60 | + |
|
61 | + /** |
|
62 | + * first or not activation |
|
63 | + * @var boolean |
|
64 | + */ |
|
65 | + private static $_bFirstActivation = true; |
|
66 | + |
|
67 | + /** |
|
68 | + * kind of report log |
|
69 | + * @var string error_log|screen|all |
|
70 | + */ |
|
71 | + private static $_sKindOfReportLog = 'error_log'; |
|
72 | + |
|
73 | + /** |
|
74 | + * instance of logger |
|
75 | + * @var \Venus\lib\Debug |
|
76 | + */ |
|
77 | + private static $_oInstance; |
|
78 | 78 | |
79 | - /** |
|
80 | - * Send back the isntance or create it |
|
81 | - * |
|
82 | - * @access public |
|
83 | - */ |
|
84 | - public static function getInstance() : Debug |
|
85 | - { |
|
86 | - if (!(self::$_oInstance instanceof self)) { self::$_oInstance = new self(); } |
|
79 | + /** |
|
80 | + * Send back the isntance or create it |
|
81 | + * |
|
82 | + * @access public |
|
83 | + */ |
|
84 | + public static function getInstance() : Debug |
|
85 | + { |
|
86 | + if (!(self::$_oInstance instanceof self)) { self::$_oInstance = new self(); } |
|
87 | 87 | |
88 | - return self::$_oInstance; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * activate debug |
|
93 | - * |
|
94 | - * @access public |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - public static function activateDebug() |
|
98 | - { |
|
99 | - if (self::$_bFirstActivation === true) { |
|
100 | - |
|
101 | - self::_setFileNameInErrorFile(); |
|
102 | - self::$_bFirstActivation = false; |
|
103 | - } |
|
104 | - |
|
105 | - self::_initLogFile(); |
|
106 | - self::$_bActivateDebug = true; |
|
107 | - self::activateError(E_ALL); |
|
108 | - self::activateException(E_ALL); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * activate debug |
|
113 | - * |
|
114 | - * @access public |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public static function deactivateDebug() |
|
118 | - { |
|
119 | - self::$_bActivateDebug = false; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * check if debug is activate or not |
|
124 | - * |
|
125 | - * @access public |
|
126 | - * @return boolean |
|
127 | - */ |
|
128 | - public static function isDebug() : bool |
|
129 | - { |
|
130 | - return self::$_bActivateDebug; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * activate error reporting |
|
135 | - * |
|
136 | - * @access public |
|
137 | - * @param int $iLevel level of error |
|
138 | - * @return void |
|
139 | - */ |
|
140 | - public static function activateError($iLevel) |
|
141 | - { |
|
142 | - if (self::$_bFirstActivation === true) { |
|
143 | - |
|
144 | - self::_setFileNameInErrorFile(); |
|
145 | - self::$_bFirstActivation = false; |
|
146 | - } |
|
147 | - |
|
148 | - self::_initLogFile(); |
|
149 | - self::$_bActivateError = true; |
|
150 | - |
|
151 | - error_reporting($iLevel); |
|
152 | - |
|
153 | - set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
154 | - { |
|
155 | - $aContext = array('file' => $sErrFile, 'line' => $iErrLine); |
|
156 | - |
|
157 | - $sType = self::getTranslateErrorCode($iErrNo); |
|
158 | - |
|
159 | - self::getInstance()->$sType($sErrStr, $aContext); |
|
160 | - |
|
161 | - return true; |
|
162 | - }, $iLevel); |
|
163 | - |
|
164 | - register_shutdown_function(function() |
|
165 | - { |
|
166 | - if (null !== ($aLastError = error_get_last())) { |
|
167 | - |
|
168 | - $aContext = array('file' => $aLastError['file'], 'line' => $aLastError['line']); |
|
169 | - |
|
170 | - $sType = self::getTranslateErrorCode($aLastError['type']); |
|
171 | - |
|
172 | - self::getInstance()->$sType($aLastError['message'], $aContext); |
|
173 | - } |
|
174 | - }); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * activate error reporting |
|
179 | - * |
|
180 | - * @access public |
|
181 | - * @return void |
|
182 | - */ |
|
183 | - public static function deactivateError() |
|
184 | - { |
|
185 | - self::$_bActivateError = false; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * check if error reporting is activate or not |
|
190 | - * |
|
191 | - * @access public |
|
192 | - * @return boolean |
|
193 | - */ |
|
194 | - public static function isError() : bool |
|
195 | - { |
|
196 | - return self::$_bActivateError; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * activate Exception |
|
202 | - * |
|
203 | - * @access public |
|
204 | - * @param int $iLevel level of error |
|
205 | - * @return void |
|
206 | - */ |
|
207 | - public static function activateException(int $iLevel) |
|
208 | - { |
|
209 | - if (self::$_bFirstActivation === true) { |
|
210 | - |
|
211 | - self::_setFileNameInErrorFile(); |
|
212 | - self::$_bFirstActivation = false; |
|
213 | - } |
|
214 | - |
|
215 | - self::_initLogFile(); |
|
216 | - self::$_bActivateException = true; |
|
217 | - |
|
218 | - set_exception_handler(function (\Exception $oException) |
|
219 | - { |
|
220 | - $aContext = array('file' => $oException->getFile(), 'line' => $oException->getLine()); |
|
221 | - self::getInstance()->critical($oException->getMessage(), $aContext); |
|
222 | - }); |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * activate Exception |
|
227 | - * |
|
228 | - * @access public |
|
229 | - * @return void |
|
230 | - */ |
|
231 | - public static function deactivateException() |
|
232 | - { |
|
233 | - self::$_bActivateException = false; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * check if Exception is activate or not |
|
238 | - * |
|
239 | - * @access public |
|
240 | - * @return boolean |
|
241 | - */ |
|
242 | - public static function isException() : bool |
|
243 | - { |
|
244 | - return self::$_bActivateException; |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * set the kind of report Log |
|
249 | - * |
|
250 | - * @access public |
|
251 | - * @param string $sKindOfReportLog |
|
252 | - * @return void |
|
253 | - */ |
|
254 | - public static function setKindOfReportLog(string $sKindOfReportLog) |
|
255 | - { |
|
256 | - if ($sKindOfReportLog === 'screen' || $sKindOfReportLog === 'all') { self::$_sKindOfReportLog = $sKindOfReportLog; } |
|
257 | - else { self::$_sKindOfReportLog = 'error_log'; } |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * get the kind of report Log |
|
262 | - * |
|
263 | - * @access public |
|
264 | - * @return string |
|
265 | - */ |
|
266 | - public static function getKindOfReportLog() : string |
|
267 | - { |
|
268 | - return self::$_sKindOfReportLog; |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * get the code by LogLevel adapt to the PSR-3 |
|
273 | - * |
|
274 | - * @access public |
|
275 | - * @param int $iCode |
|
276 | - * @return string |
|
277 | - */ |
|
278 | - public static function getTranslateErrorCode(int $iCode) : string |
|
279 | - { |
|
280 | - if ($iCode === 1 && $iCode === 16 && $iCode === 256 && $iCode === 4096) { return LogLevel::ERROR; } |
|
281 | - else if ($iCode === 2 && $iCode === 32 && $iCode === 128 && $iCode === 512) { return LogLevel::WARNING; } |
|
282 | - else if ($iCode === 4 && $iCode === 64) { return LogLevel::EMERGENCY; } |
|
283 | - else if ($iCode === 8 && $iCode === 1024) { return LogLevel::NOTICE; } |
|
284 | - else if ($iCode === 2048 && $iCode === 8192 && $iCode === 16384) { return LogLevel::INFO; } |
|
285 | - else return LogLevel::DEBUG; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * System is unusable. |
|
290 | - * |
|
291 | - * @param string $message |
|
292 | - * @param array $context |
|
293 | - * @return null |
|
294 | - */ |
|
295 | - public function emergency($message, array $context = array()) |
|
296 | - { |
|
297 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Action must be taken immediately. |
|
302 | - * |
|
303 | - * Example: Entire website down, database unavailable, etc. This should |
|
304 | - * trigger the SMS alerts and wake you up. |
|
305 | - * |
|
306 | - * @param string $message |
|
307 | - * @param array $context |
|
308 | - * @return null |
|
309 | - */ |
|
310 | - public function alert($message, array $context = array()) |
|
311 | - { |
|
312 | - $this->log(LogLevel::ALERT, $message, $context); |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Critical conditions. |
|
317 | - * |
|
318 | - * Example: Application component unavailable, unexpected exception. |
|
319 | - * |
|
320 | - * @param string $message |
|
321 | - * @param array $context |
|
322 | - * @return null |
|
323 | - */ |
|
324 | - public function critical($message, array $context = array()) |
|
325 | - { |
|
326 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
327 | - } |
|
328 | - |
|
329 | - /** |
|
330 | - * Runtime errors that do not require immediate action but should typically |
|
331 | - * be logged and monitored. |
|
332 | - * |
|
333 | - * @param string $message |
|
334 | - * @param array $context |
|
335 | - * @return null |
|
336 | - */ |
|
337 | - public function error($message, array $context = array()) |
|
338 | - { |
|
339 | - $this->log(LogLevel::ERROR, $message, $context); |
|
340 | - } |
|
341 | - |
|
342 | - /** |
|
343 | - * Exceptional occurrences that are not errors. |
|
344 | - * |
|
345 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
346 | - * that are not necessarily wrong. |
|
347 | - * |
|
348 | - * @param string $message |
|
349 | - * @param array $context |
|
350 | - * @return null |
|
351 | - */ |
|
352 | - public function warning($message, array $context = array()) |
|
353 | - { |
|
354 | - $this->log(LogLevel::WARNING, $message, $context); |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Normal but significant events. |
|
359 | - * |
|
360 | - * @param string $message |
|
361 | - * @param array $context |
|
362 | - * @return null |
|
363 | - */ |
|
364 | - public function notice($message, array $context = array()) |
|
365 | - { |
|
366 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
367 | - } |
|
368 | - |
|
369 | - /** |
|
370 | - * Interesting events. |
|
371 | - * |
|
372 | - * Example: User logs in, SQL logs. |
|
373 | - * |
|
374 | - * @param string $message |
|
375 | - * @param array $context |
|
376 | - * @return null |
|
377 | - */ |
|
378 | - public function info($message, array $context = array()) |
|
379 | - { |
|
380 | - $this->log(LogLevel::INFO, $message, $context); |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * Detailed debug information. |
|
385 | - * |
|
386 | - * @param string $message |
|
387 | - * @param array $context |
|
388 | - * @return null |
|
389 | - */ |
|
390 | - public function debug($message, array $context = array()) |
|
391 | - { |
|
392 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * set the name of the called |
|
397 | - * |
|
398 | - * @access public |
|
399 | - * @return void |
|
400 | - */ |
|
401 | - private static function _setFileNameInErrorFile() |
|
402 | - { |
|
403 | - /** |
|
404 | - * We see if it's a cli call or a web call |
|
405 | - */ |
|
406 | - |
|
407 | - if (defined('BASH_CALLED')) { |
|
408 | - |
|
409 | - error_log(Bash::setColor('############### '.BASH_CALLED.' ###############', 'cyan')); |
|
410 | - } |
|
411 | - else { |
|
412 | - |
|
413 | - if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
|
414 | - error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
|
415 | - } |
|
416 | - } |
|
417 | - } |
|
418 | - |
|
419 | - /** |
|
420 | - * init the log file (error_log) |
|
421 | - * |
|
422 | - * @access private |
|
423 | - * @return void |
|
424 | - */ |
|
425 | - private static function _initLogFile() |
|
426 | - { |
|
427 | - self::$_sFileLog = str_replace(DIRECTORY_SEPARATOR.'bundles'.DIRECTORY_SEPARATOR.'lib', '', __DIR__).DIRECTORY_SEPARATOR. |
|
428 | - "data".DIRECTORY_SEPARATOR."log".DIRECTORY_SEPARATOR."php-error.log"; |
|
429 | - |
|
430 | - ini_set("log_errors", 1); |
|
431 | - ini_set("error_log", self::$_sFileLog); |
|
432 | - |
|
433 | - if (file_exists(self::$_sFileLog) === false) { file_put_contents(self::$_sFileLog, ''); } |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * constructor in private for the singleton |
|
438 | - * |
|
439 | - * @access private |
|
440 | - * @return \Venus\lib\Debug |
|
441 | - */ |
|
442 | - private function __construct() {} |
|
443 | - |
|
444 | - /** |
|
445 | - * not allowed to clone a object |
|
446 | - * |
|
447 | - * @access private |
|
448 | - * @return \Venus\lib\Debug |
|
449 | - */ |
|
450 | - private function __clone() {} |
|
88 | + return self::$_oInstance; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * activate debug |
|
93 | + * |
|
94 | + * @access public |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + public static function activateDebug() |
|
98 | + { |
|
99 | + if (self::$_bFirstActivation === true) { |
|
100 | + |
|
101 | + self::_setFileNameInErrorFile(); |
|
102 | + self::$_bFirstActivation = false; |
|
103 | + } |
|
104 | + |
|
105 | + self::_initLogFile(); |
|
106 | + self::$_bActivateDebug = true; |
|
107 | + self::activateError(E_ALL); |
|
108 | + self::activateException(E_ALL); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * activate debug |
|
113 | + * |
|
114 | + * @access public |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public static function deactivateDebug() |
|
118 | + { |
|
119 | + self::$_bActivateDebug = false; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * check if debug is activate or not |
|
124 | + * |
|
125 | + * @access public |
|
126 | + * @return boolean |
|
127 | + */ |
|
128 | + public static function isDebug() : bool |
|
129 | + { |
|
130 | + return self::$_bActivateDebug; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * activate error reporting |
|
135 | + * |
|
136 | + * @access public |
|
137 | + * @param int $iLevel level of error |
|
138 | + * @return void |
|
139 | + */ |
|
140 | + public static function activateError($iLevel) |
|
141 | + { |
|
142 | + if (self::$_bFirstActivation === true) { |
|
143 | + |
|
144 | + self::_setFileNameInErrorFile(); |
|
145 | + self::$_bFirstActivation = false; |
|
146 | + } |
|
147 | + |
|
148 | + self::_initLogFile(); |
|
149 | + self::$_bActivateError = true; |
|
150 | + |
|
151 | + error_reporting($iLevel); |
|
152 | + |
|
153 | + set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
154 | + { |
|
155 | + $aContext = array('file' => $sErrFile, 'line' => $iErrLine); |
|
156 | + |
|
157 | + $sType = self::getTranslateErrorCode($iErrNo); |
|
158 | + |
|
159 | + self::getInstance()->$sType($sErrStr, $aContext); |
|
160 | + |
|
161 | + return true; |
|
162 | + }, $iLevel); |
|
163 | + |
|
164 | + register_shutdown_function(function() |
|
165 | + { |
|
166 | + if (null !== ($aLastError = error_get_last())) { |
|
167 | + |
|
168 | + $aContext = array('file' => $aLastError['file'], 'line' => $aLastError['line']); |
|
169 | + |
|
170 | + $sType = self::getTranslateErrorCode($aLastError['type']); |
|
171 | + |
|
172 | + self::getInstance()->$sType($aLastError['message'], $aContext); |
|
173 | + } |
|
174 | + }); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * activate error reporting |
|
179 | + * |
|
180 | + * @access public |
|
181 | + * @return void |
|
182 | + */ |
|
183 | + public static function deactivateError() |
|
184 | + { |
|
185 | + self::$_bActivateError = false; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * check if error reporting is activate or not |
|
190 | + * |
|
191 | + * @access public |
|
192 | + * @return boolean |
|
193 | + */ |
|
194 | + public static function isError() : bool |
|
195 | + { |
|
196 | + return self::$_bActivateError; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * activate Exception |
|
202 | + * |
|
203 | + * @access public |
|
204 | + * @param int $iLevel level of error |
|
205 | + * @return void |
|
206 | + */ |
|
207 | + public static function activateException(int $iLevel) |
|
208 | + { |
|
209 | + if (self::$_bFirstActivation === true) { |
|
210 | + |
|
211 | + self::_setFileNameInErrorFile(); |
|
212 | + self::$_bFirstActivation = false; |
|
213 | + } |
|
214 | + |
|
215 | + self::_initLogFile(); |
|
216 | + self::$_bActivateException = true; |
|
217 | + |
|
218 | + set_exception_handler(function (\Exception $oException) |
|
219 | + { |
|
220 | + $aContext = array('file' => $oException->getFile(), 'line' => $oException->getLine()); |
|
221 | + self::getInstance()->critical($oException->getMessage(), $aContext); |
|
222 | + }); |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * activate Exception |
|
227 | + * |
|
228 | + * @access public |
|
229 | + * @return void |
|
230 | + */ |
|
231 | + public static function deactivateException() |
|
232 | + { |
|
233 | + self::$_bActivateException = false; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * check if Exception is activate or not |
|
238 | + * |
|
239 | + * @access public |
|
240 | + * @return boolean |
|
241 | + */ |
|
242 | + public static function isException() : bool |
|
243 | + { |
|
244 | + return self::$_bActivateException; |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * set the kind of report Log |
|
249 | + * |
|
250 | + * @access public |
|
251 | + * @param string $sKindOfReportLog |
|
252 | + * @return void |
|
253 | + */ |
|
254 | + public static function setKindOfReportLog(string $sKindOfReportLog) |
|
255 | + { |
|
256 | + if ($sKindOfReportLog === 'screen' || $sKindOfReportLog === 'all') { self::$_sKindOfReportLog = $sKindOfReportLog; } |
|
257 | + else { self::$_sKindOfReportLog = 'error_log'; } |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * get the kind of report Log |
|
262 | + * |
|
263 | + * @access public |
|
264 | + * @return string |
|
265 | + */ |
|
266 | + public static function getKindOfReportLog() : string |
|
267 | + { |
|
268 | + return self::$_sKindOfReportLog; |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * get the code by LogLevel adapt to the PSR-3 |
|
273 | + * |
|
274 | + * @access public |
|
275 | + * @param int $iCode |
|
276 | + * @return string |
|
277 | + */ |
|
278 | + public static function getTranslateErrorCode(int $iCode) : string |
|
279 | + { |
|
280 | + if ($iCode === 1 && $iCode === 16 && $iCode === 256 && $iCode === 4096) { return LogLevel::ERROR; } |
|
281 | + else if ($iCode === 2 && $iCode === 32 && $iCode === 128 && $iCode === 512) { return LogLevel::WARNING; } |
|
282 | + else if ($iCode === 4 && $iCode === 64) { return LogLevel::EMERGENCY; } |
|
283 | + else if ($iCode === 8 && $iCode === 1024) { return LogLevel::NOTICE; } |
|
284 | + else if ($iCode === 2048 && $iCode === 8192 && $iCode === 16384) { return LogLevel::INFO; } |
|
285 | + else return LogLevel::DEBUG; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * System is unusable. |
|
290 | + * |
|
291 | + * @param string $message |
|
292 | + * @param array $context |
|
293 | + * @return null |
|
294 | + */ |
|
295 | + public function emergency($message, array $context = array()) |
|
296 | + { |
|
297 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Action must be taken immediately. |
|
302 | + * |
|
303 | + * Example: Entire website down, database unavailable, etc. This should |
|
304 | + * trigger the SMS alerts and wake you up. |
|
305 | + * |
|
306 | + * @param string $message |
|
307 | + * @param array $context |
|
308 | + * @return null |
|
309 | + */ |
|
310 | + public function alert($message, array $context = array()) |
|
311 | + { |
|
312 | + $this->log(LogLevel::ALERT, $message, $context); |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Critical conditions. |
|
317 | + * |
|
318 | + * Example: Application component unavailable, unexpected exception. |
|
319 | + * |
|
320 | + * @param string $message |
|
321 | + * @param array $context |
|
322 | + * @return null |
|
323 | + */ |
|
324 | + public function critical($message, array $context = array()) |
|
325 | + { |
|
326 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
327 | + } |
|
328 | + |
|
329 | + /** |
|
330 | + * Runtime errors that do not require immediate action but should typically |
|
331 | + * be logged and monitored. |
|
332 | + * |
|
333 | + * @param string $message |
|
334 | + * @param array $context |
|
335 | + * @return null |
|
336 | + */ |
|
337 | + public function error($message, array $context = array()) |
|
338 | + { |
|
339 | + $this->log(LogLevel::ERROR, $message, $context); |
|
340 | + } |
|
341 | + |
|
342 | + /** |
|
343 | + * Exceptional occurrences that are not errors. |
|
344 | + * |
|
345 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
346 | + * that are not necessarily wrong. |
|
347 | + * |
|
348 | + * @param string $message |
|
349 | + * @param array $context |
|
350 | + * @return null |
|
351 | + */ |
|
352 | + public function warning($message, array $context = array()) |
|
353 | + { |
|
354 | + $this->log(LogLevel::WARNING, $message, $context); |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Normal but significant events. |
|
359 | + * |
|
360 | + * @param string $message |
|
361 | + * @param array $context |
|
362 | + * @return null |
|
363 | + */ |
|
364 | + public function notice($message, array $context = array()) |
|
365 | + { |
|
366 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
367 | + } |
|
368 | + |
|
369 | + /** |
|
370 | + * Interesting events. |
|
371 | + * |
|
372 | + * Example: User logs in, SQL logs. |
|
373 | + * |
|
374 | + * @param string $message |
|
375 | + * @param array $context |
|
376 | + * @return null |
|
377 | + */ |
|
378 | + public function info($message, array $context = array()) |
|
379 | + { |
|
380 | + $this->log(LogLevel::INFO, $message, $context); |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Detailed debug information. |
|
385 | + * |
|
386 | + * @param string $message |
|
387 | + * @param array $context |
|
388 | + * @return null |
|
389 | + */ |
|
390 | + public function debug($message, array $context = array()) |
|
391 | + { |
|
392 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * set the name of the called |
|
397 | + * |
|
398 | + * @access public |
|
399 | + * @return void |
|
400 | + */ |
|
401 | + private static function _setFileNameInErrorFile() |
|
402 | + { |
|
403 | + /** |
|
404 | + * We see if it's a cli call or a web call |
|
405 | + */ |
|
406 | + |
|
407 | + if (defined('BASH_CALLED')) { |
|
408 | + |
|
409 | + error_log(Bash::setColor('############### '.BASH_CALLED.' ###############', 'cyan')); |
|
410 | + } |
|
411 | + else { |
|
412 | + |
|
413 | + if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
|
414 | + error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | + |
|
419 | + /** |
|
420 | + * init the log file (error_log) |
|
421 | + * |
|
422 | + * @access private |
|
423 | + * @return void |
|
424 | + */ |
|
425 | + private static function _initLogFile() |
|
426 | + { |
|
427 | + self::$_sFileLog = str_replace(DIRECTORY_SEPARATOR.'bundles'.DIRECTORY_SEPARATOR.'lib', '', __DIR__).DIRECTORY_SEPARATOR. |
|
428 | + "data".DIRECTORY_SEPARATOR."log".DIRECTORY_SEPARATOR."php-error.log"; |
|
429 | + |
|
430 | + ini_set("log_errors", 1); |
|
431 | + ini_set("error_log", self::$_sFileLog); |
|
432 | + |
|
433 | + if (file_exists(self::$_sFileLog) === false) { file_put_contents(self::$_sFileLog, ''); } |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * constructor in private for the singleton |
|
438 | + * |
|
439 | + * @access private |
|
440 | + * @return \Venus\lib\Debug |
|
441 | + */ |
|
442 | + private function __construct() {} |
|
443 | + |
|
444 | + /** |
|
445 | + * not allowed to clone a object |
|
446 | + * |
|
447 | + * @access private |
|
448 | + * @return \Venus\lib\Debug |
|
449 | + */ |
|
450 | + private function __clone() {} |
|
451 | 451 | } |
@@ -28,126 +28,126 @@ |
||
28 | 28 | */ |
29 | 29 | class Bash |
30 | 30 | { |
31 | - /** |
|
32 | - * color of the text in the bash |
|
33 | - * |
|
34 | - * @access public |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - public static $_aColorCodes = array( |
|
38 | - 'default' => 39, |
|
39 | - 'black' => 30, |
|
40 | - 'red' => 31, |
|
41 | - 'green' => 32, |
|
42 | - 'yellow' => 33, |
|
43 | - 'blue' => 34, |
|
44 | - 'magenta' => 35, |
|
45 | - 'cyan' => 36, |
|
46 | - 'light gray' => 37, |
|
47 | - 'dark gray' => 90, |
|
48 | - 'light red' => 91, |
|
49 | - 'light green' => 92, |
|
50 | - 'light yellow' => 93, |
|
51 | - 'light blue' => 94, |
|
52 | - 'light magenta' => 95, |
|
53 | - 'light cyan' => 96, |
|
54 | - 'white' => 97 |
|
55 | - ); |
|
31 | + /** |
|
32 | + * color of the text in the bash |
|
33 | + * |
|
34 | + * @access public |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + public static $_aColorCodes = array( |
|
38 | + 'default' => 39, |
|
39 | + 'black' => 30, |
|
40 | + 'red' => 31, |
|
41 | + 'green' => 32, |
|
42 | + 'yellow' => 33, |
|
43 | + 'blue' => 34, |
|
44 | + 'magenta' => 35, |
|
45 | + 'cyan' => 36, |
|
46 | + 'light gray' => 37, |
|
47 | + 'dark gray' => 90, |
|
48 | + 'light red' => 91, |
|
49 | + 'light green' => 92, |
|
50 | + 'light yellow' => 93, |
|
51 | + 'light blue' => 94, |
|
52 | + 'light magenta' => 95, |
|
53 | + 'light cyan' => 96, |
|
54 | + 'white' => 97 |
|
55 | + ); |
|
56 | 56 | |
57 | - /** |
|
58 | - * color of the background in the bash |
|
59 | - * |
|
60 | - * @access public |
|
61 | - * @var array |
|
62 | - */ |
|
63 | - public static $_aBackgroundCodes = array( |
|
64 | - 'default' => 49, |
|
65 | - 'black' => 40, |
|
66 | - 'red' => 41, |
|
67 | - 'green' => 42, |
|
68 | - 'yellow' => 43, |
|
69 | - 'blue' => 44, |
|
70 | - 'magenta' => 45, |
|
71 | - 'cyan' => 46, |
|
72 | - 'light gray' => 47, |
|
73 | - 'dark gray' => 100, |
|
74 | - 'light red' => 101, |
|
75 | - 'light green' => 102, |
|
76 | - 'light yellow' => 103, |
|
77 | - 'light blue' => 104, |
|
78 | - 'light magenta' => 105, |
|
79 | - 'light cyan' => 106, |
|
80 | - 'white' => 107 |
|
81 | - ); |
|
57 | + /** |
|
58 | + * color of the background in the bash |
|
59 | + * |
|
60 | + * @access public |
|
61 | + * @var array |
|
62 | + */ |
|
63 | + public static $_aBackgroundCodes = array( |
|
64 | + 'default' => 49, |
|
65 | + 'black' => 40, |
|
66 | + 'red' => 41, |
|
67 | + 'green' => 42, |
|
68 | + 'yellow' => 43, |
|
69 | + 'blue' => 44, |
|
70 | + 'magenta' => 45, |
|
71 | + 'cyan' => 46, |
|
72 | + 'light gray' => 47, |
|
73 | + 'dark gray' => 100, |
|
74 | + 'light red' => 101, |
|
75 | + 'light green' => 102, |
|
76 | + 'light yellow' => 103, |
|
77 | + 'light blue' => 104, |
|
78 | + 'light magenta' => 105, |
|
79 | + 'light cyan' => 106, |
|
80 | + 'white' => 107 |
|
81 | + ); |
|
82 | 82 | |
83 | - /** |
|
84 | - * color of the decoration code in the bash |
|
85 | - * |
|
86 | - * @access public |
|
87 | - * @var array |
|
88 | - */ |
|
89 | - public static $_aDecorationCodes = array( |
|
90 | - 'bold' => '1', |
|
91 | - 'dim' => '2', |
|
92 | - 'underline' => '4', |
|
93 | - 'blink' => '5', |
|
94 | - 'reverse' => '7', |
|
95 | - 'hidden' => '8' |
|
96 | - ); |
|
83 | + /** |
|
84 | + * color of the decoration code in the bash |
|
85 | + * |
|
86 | + * @access public |
|
87 | + * @var array |
|
88 | + */ |
|
89 | + public static $_aDecorationCodes = array( |
|
90 | + 'bold' => '1', |
|
91 | + 'dim' => '2', |
|
92 | + 'underline' => '4', |
|
93 | + 'blink' => '5', |
|
94 | + 'reverse' => '7', |
|
95 | + 'hidden' => '8' |
|
96 | + ); |
|
97 | 97 | |
98 | - /** |
|
99 | - * set a decoration of the text |
|
100 | - * |
|
101 | - * @access public |
|
102 | - * @param string $sContent content to around by the style |
|
103 | - * @param string $sStyleName the name of the style |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - public static function setDecoration(string $sContent, string $sStyleName) : string |
|
107 | - { |
|
108 | - return self::_applyCode($sContent, self::$_aBackgroundCodes[$sStyleName]); |
|
109 | - } |
|
98 | + /** |
|
99 | + * set a decoration of the text |
|
100 | + * |
|
101 | + * @access public |
|
102 | + * @param string $sContent content to around by the style |
|
103 | + * @param string $sStyleName the name of the style |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + public static function setDecoration(string $sContent, string $sStyleName) : string |
|
107 | + { |
|
108 | + return self::_applyCode($sContent, self::$_aBackgroundCodes[$sStyleName]); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * set a color of the background |
|
113 | - * |
|
114 | - * @access public |
|
115 | - * @param string $sContent content to around by the style |
|
116 | - * @param string $sColorName the name of the color |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public static function setBackground(string $sContent, string $sColorName) : string |
|
120 | - { |
|
121 | - if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'black'; } |
|
111 | + /** |
|
112 | + * set a color of the background |
|
113 | + * |
|
114 | + * @access public |
|
115 | + * @param string $sContent content to around by the style |
|
116 | + * @param string $sColorName the name of the color |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public static function setBackground(string $sContent, string $sColorName) : string |
|
120 | + { |
|
121 | + if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'black'; } |
|
122 | 122 | |
123 | - return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); |
|
124 | - } |
|
123 | + return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * set a color of the text |
|
128 | - * |
|
129 | - * @access public |
|
130 | - * @param string $sContent content to around by the style |
|
131 | - * @param string $sColorName the name of the color |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public static function setColor(string $sContent, string $sColorName) : string |
|
135 | - { |
|
136 | - if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'white'; } |
|
126 | + /** |
|
127 | + * set a color of the text |
|
128 | + * |
|
129 | + * @access public |
|
130 | + * @param string $sContent content to around by the style |
|
131 | + * @param string $sColorName the name of the color |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public static function setColor(string $sContent, string $sColorName) : string |
|
135 | + { |
|
136 | + if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'white'; } |
|
137 | 137 | |
138 | - return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); |
|
139 | - } |
|
138 | + return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * around the text by a color |
|
143 | - * |
|
144 | - * @access private |
|
145 | - * @param string $sContent content to around by the style |
|
146 | - * @param string $sCode the name of the code (color or decoration) |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - private static function _applyCode(string $sContent, string $sCode) : string |
|
150 | - { |
|
151 | - return "\033[" . $sCode . "m" . $sContent . "\033[0m\n"; |
|
152 | - } |
|
141 | + /** |
|
142 | + * around the text by a color |
|
143 | + * |
|
144 | + * @access private |
|
145 | + * @param string $sContent content to around by the style |
|
146 | + * @param string $sCode the name of the code (color or decoration) |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + private static function _applyCode(string $sContent, string $sCode) : string |
|
150 | + { |
|
151 | + return "\033[" . $sCode . "m" . $sContent . "\033[0m\n"; |
|
152 | + } |
|
153 | 153 | } |
@@ -148,6 +148,6 @@ |
||
148 | 148 | */ |
149 | 149 | private static function _applyCode(string $sContent, string $sCode) : string |
150 | 150 | { |
151 | - return "\033[" . $sCode . "m" . $sContent . "\033[0m\n"; |
|
151 | + return "\033[".$sCode."m".$sContent."\033[0m\n"; |
|
152 | 152 | } |
153 | 153 | } |
@@ -129,7 +129,7 @@ |
||
129 | 129 | * @param mixed $mOffset |
130 | 130 | * @return boolean |
131 | 131 | */ |
132 | - public function offsetExists($mOffset) |
|
132 | + public function offsetExists($mOffset) |
|
133 | 133 | { |
134 | 134 | return $this->__isset($mOffset); |
135 | 135 | } |