Completed
Push — master ( f8fad3...d6dee8 )
by Anton
9s
created

_functions.php ➔ errorHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Simple functions of Application
4
 * be careful with this way
5
 * @author  Anton Shevchuk
6
 * @created 25.07.13 13:34
7
 */
8
9
/**
10
 * @namespace
11
 */
12
namespace Application;
13
14
/**
15
 * Write message to log file
16
 *
17
 * @param integer $severity
18
 * @param string  $message
19
 * @param string  $file
20
 * @param integer $line
21
 * @throws \ErrorException
22
 */
23
function errorHandler($severity, $message, $file = null, $line = null)
24
{
25
    throw new \ErrorException($message, 0, $severity, $file, $line);
26
}
27
28
/**
29
 * Write Exception to log file
30
 *
31
 * @param \Throwable $exception
32
 * @return bool
33
 */
34
function errorLog($exception)
35
{
36
    if (getenv('BLUZ_LOG') && is_dir(PATH_DATA .'/logs') && is_writable(PATH_DATA .'/logs')) {
37
        // [Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /var/www/...
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
        $message = "[".date("r")."] [".get_class($exception)."] "
39
            . ($exception->getFile()) .':'. ($exception->getLine())
40
            . ":\t"
41
            . trim($exception->getMessage())
42
            . "\n"
43
        ;
44
45
        // write log
46
        file_put_contents(
47
            PATH_DATA .'/logs/'.(date('Y-m-d')).'.log',
48
            $message,
49
            FILE_APPEND | LOCK_EX
50
        );
51
    }
52
53
    return false;
54
}
55