Passed
Push — develop ( 24632c...341ec8 )
by Anton
12:02
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 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