Passed
Push — develop ( 788941...24632c )
by Anton
13:36
created

errorHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 4
dl 0
loc 3
ccs 0
cts 1
cp 0
c 0
b 0
f 0
cc 1
crap 2
rs 10
1
<?php
2
/**
3
 * Simple functions of Application
4
 * be careful with this way
5
 */
6
7
namespace Application;
8
9
/**
10
 * Write message to log file
11
 *
12
 * @param integer $severity
13
 * @param string  $message
14
 * @param string  $file
15
 * @param integer $line
16
 *
17
 * @throws \ErrorException
18
 */
19
function errorHandler($severity, $message, $file = null, $line = null)
20
{
21
    throw new \ErrorException($message, 0, $severity, $file, $line);
22
}
23
24
/**
25
 * Write Exception to log file
26
 *
27
 * @param \Throwable $exception
28
 *
29
 * @return void
30
 */
31
function errorLog($exception)
32
{
33
    if (getenv('BLUZ_LOG') && is_dir(PATH_DATA . '/logs') && is_writable(PATH_DATA . '/logs')) {
34
        // [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...
35
        $message = '[' . date('r') . '] [' . get_class($exception) . '] '
36
            . '[' . $_SERVER['REQUEST_URI'] . ']'
37
            . $exception->getFile() . ':' . $exception->getLine()
38
            . ': '
39
            . trim($exception->getMessage())
40
            . "\n";
41
42
        // write log
43
        file_put_contents(
44
            PATH_DATA . '/logs/' . date('Y-m-d') . '.log',
45
            $message,
46
            FILE_APPEND | LOCK_EX
47
        );
48
    }
49
}
50