Conditions | 6 |
Paths | 8 |
Total Lines | 33 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
17 | public static function log($e) |
||
18 | { |
||
19 | $logFile = Executor::getInstance()->getConfig()->getLogFile(); |
||
20 | $type = "\\Exception"; |
||
21 | $pattern = "%s"; |
||
22 | |||
23 | if ($e instanceof AbstractException) { |
||
24 | $type = $e->getType(); |
||
25 | $pattern = $e->getColorMessagePattern(); |
||
26 | } |
||
27 | |||
28 | if ($logFile && (!file_exists($logFile) || is_writable($logFile))) { |
||
|
|||
29 | $fh = fopen($logFile, "a"); |
||
30 | |||
31 | $logString = sprintf( |
||
32 | "[%s] [%s] %s\n", |
||
33 | date("H:i:s d.m.Y"), |
||
34 | $type, |
||
35 | $e->getMessage() |
||
36 | ); |
||
37 | fwrite($fh, $logString); |
||
38 | fclose($fh); |
||
39 | } else { |
||
40 | echo sprintf( |
||
41 | $pattern, |
||
42 | $e->getMessage() |
||
43 | ). "\n"; |
||
44 | } |
||
45 | |||
46 | if ($e instanceof Fatal) { |
||
47 | exit; |
||
48 | } |
||
49 | } |
||
50 | } |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: