Completed
Push — master ( d2992a...8fe16f )
by Michał
06:47
created

LogStatic   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 71
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A log() 0 5 1
A makeLog() 0 5 1
A setOption() 0 5 1
A getOption() 0 5 1
A init() 0 6 2
1
<?php
2
3
namespace SimpleLog;
4
5
class LogStatic
6
{
7
    /**
8
     * @var Log
9
     */
10
    protected static $instance;
11
12
    /**
13
     * log event information into file
14
     *
15
     * @param string $level
16
     * @param array|string $message
17
     * @param array $context
18
     * @param array $params
19
     */
20
    public static function log($level, $message, array $context = [], array $params = [])
21
    {
22
        self::init($params);
23
        self::$instance->log($level, $message, $context);
24
    }
25
26
    /**
27
     * log event information into file
28
     *
29
     * @param array|string $message
30
     * @param array $context
31
     * @param array $params
32
     */
33
    public static function makeLog($message, array $context = [], array $params = [])
34
    {
35
        self::init($params);
36
        self::$instance->makeLog($message, $context);
37
    }
38
39
    /**
40
     * set log option for all future executions of makeLog
41
     *
42
     * @param string $key
43
     * @param mixed $val
44
     * @return Log
45
     */
46
    public static function setOption($key, $val)
47
    {
48
        self::init();
49
        return self::$instance->setOption($key, $val);
50
    }
51
52
    /**
53
     * return all configuration or only given key value
54
     *
55
     * @param null|string $key
56
     * @return array|mixed
57
     */
58
    public static function getOption($key = null)
59
    {
60
        self::init();
61
        return self::$instance->getOption($key);
62
    }
63
64
    /**
65
     * create Log object if not exists
66
     *
67
     * @param array $params
68
     */
69
    protected static function init(array $params = [])
70
    {
71
        if (is_null(self::$instance)) {
72
            self::$instance = new Log($params);
73
        }
74
    }
75
}
76