Logger::log()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Arrilot\BitrixMigrations;
4
5
class Logger
6
{
7
    const COLOR_BLACK = '0;30';
8
    const COLOR_DARK_GRAY = '1;30';
9
    const COLOR_BLUE = '0;34';
10
    const COLOR_LIGHT_BLUE = '1;34';
11
    const COLOR_GREEN = '0;32';
12
    const COLOR_LIGHT_GREEN = '1;32';
13
    const COLOR_CYAN = '0;36';
14
    const COLOR_LIGHT_CYAN = '1;36';
15
    const COLOR_RED = '0;31';
16
    const COLOR_LIGHT_RED = '1;31';
17
    const COLOR_PURPLE = '0;35';
18
    const COLOR_LIGHT_PURPLE = '1;35';
19
    const COLOR_BROWN = '0;33';
20
    const COLOR_YELLOW = '1;33';
21
    const COLOR_LIGHT_GRAY = '0;37';
22
    const COLOR_WHITE = '1;37';
23
24
    public static function log($string, $foreground_color = null)
25
    {
26
        $colored_string = "";
27
28
        if ($foreground_color) {
29
            $colored_string .= "\033[" . $foreground_color . "m";
30
        }
31
32
        $colored_string .= $string . "\033[0m\n";
33
34
        fwrite(STDOUT, $colored_string);
35
    }
36
}
37