Completed
Push — master ( 075767...680728 )
by Anton
05:11 queued 05:08
created

_functions.php ➔ errorLog()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

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