Configuration   A
last analyzed

Complexity

Total Complexity 19

Size/Duplication

Total Lines 210
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 210
rs 10
c 0
b 0
f 0
wmc 19

14 Methods

Rating   Name   Duplication   Size   Complexity  
A setTag() 0 4 1
A getLoggerFileFormat() 0 7 2
A getConsoleVerbosity() 0 7 2
A setLoggerConsoleFormat() 0 4 1
A setLogfile() 0 4 1
A getLoggerConsoleFormat() 0 7 2
A getLevel() 0 3 1
A setConsoleVerbosity() 0 4 1
A getVerbosity() 0 7 2
A getTag() 0 7 2
A setLoggerFileFormat() 0 4 1
A getColours() 0 3 1
A getLogfile() 0 3 1
A setVerbosity() 0 4 1
1
<?php
2
namespace SimpleLogger;
3
4
use Psr\Log\LogLevel;
5
use SimpleLogger\LogLevelMap;
6
7
class Configuration extends LogLevelMap
8
{
9
    /**
10
     * Log file name.
11
     *
12
     * @var string
13
     */
14
    public $logfile = null;
15
16
    /**
17
     * Default tag
18
     *
19
     * @var string
20
     */
21
    public $tag = null;
22
23
    /**
24
     * Default log level.
25
     *
26
     * @var int
27
     */
28
    public $verbosity = null;
29
    
30
    /**
31
     * Default log level (console).
32
     *
33
     * @var int
34
     */
35
    public $console_verbosity = null;
36
37
    /**
38
     * Console log line format.
39
     *
40
     * @var string
41
     */
42
    public $console_format = null;
43
44
    /**
45
     * File log line format.
46
     *
47
     * @var string
48
     */
49
    public $file_format = null;
50
51
    /**
52
     * Sets log file name.
53
     *
54
     * @param  string $logfile log file name
55
     * @return object
56
     */
57
    final public function setLogfile($logfile)
58
    {
59
        $this->logfile = $logfile;
60
        return $this;
61
    }
62
63
    /**
64
     * Sets log line tag.
65
     *
66
     * @param  string $tag tag
67
     * @return object
68
     */
69
    final public function setTag($tag)
70
    {
71
        $this->tag = $tag;
72
        return $this;
73
    }
74
75
    /**
76
     * Sets log level verbosity.
77
     *
78
     * @param  int     $verbosity log verbosity
79
     * @return object
80
     */
81
    final public function setVerbosity($verbosity)
82
    {
83
        $this->verbosity = $this->getLevel($verbosity);
84
        return $this;
85
    }
86
87
    /**
88
     * Sets log level verbosity.
89
     *
90
     * @param  int     $verbosity log verbosity
91
     * @return object
92
     */
93
    final public function setConsoleVerbosity($verbosity)
94
    {
95
        $this->console_verbosity = $this->getLevel($verbosity);
96
        return $this;
97
    }
98
99
    /**
100
     * Sets console log line format.
101
     *
102
     * @param  int     $format log line format
103
     * @return object
104
     */
105
    final public function setLoggerConsoleFormat($format)
106
    {
107
        $this->console_format = $format;
108
        return $this;
109
    }
110
111
    /**
112
     * Sets file log line format.
113
     *
114
     * @param  int     $format log line format
115
     * @return object
116
     */
117
    final public function setLoggerFileFormat($format)
118
    {
119
        $this->file_format = $format;
120
        return $this;
121
    }
122
123
    /**
124
     * Gets log file name.
125
     *
126
     * @return string
127
     */
128
    final public function getLogfile()
129
    {
130
        return $this->logfile;
131
    }
132
133
    /**
134
     * Gets tag
135
     *
136
     * @return string
137
     */
138
    final public function getTag()
139
    {
140
        if ($this->tag === null)
0 ignored issues
show
introduced by
The condition $this->tag === null can never be true.
Loading history...
141
        {
142
            $this->tag = 'NA';
143
        }
144
        return $this->tag;
145
    }
146
147
    /**
148
     * Gets log level verbosity.
149
     *
150
     * @return string
151
     */
152
    final public function getVerbosity()
153
    {
154
        if ($this->verbosity === null)
0 ignored issues
show
introduced by
The condition $this->verbosity === null can never be true.
Loading history...
155
        {
156
            $this->verbosity = $this->getLevel(LogLevel::DEBUG);
157
        }
158
        return $this->verbosity;
159
    }
160
    
161
    /**
162
     * Gets log level verbosity.
163
     *
164
     * @return string
165
     */
166
    final public function getConsoleVerbosity()
167
    {
168
        if ($this->console_verbosity === null)
0 ignored issues
show
introduced by
The condition $this->console_verbosity === null can never be true.
Loading history...
169
        {
170
            $this->console_verbosity = $this->getLevel(LogLevel::DEBUG);
171
        }
172
        return $this->console_verbosity;
173
    }
174
175
    /**
176
     * Gets log line format.
177
     *
178
     * @return string
179
     */
180
    final public function getLoggerConsoleFormat()
181
    {
182
        if ($this->console_format === null)
0 ignored issues
show
introduced by
The condition $this->console_format === null can never be true.
Loading history...
183
        {
184
            $this->console_format = "%t %l %c:%f - %m";
185
        }
186
        return $this->console_format;
187
    }
188
189
    /**
190
     * Gets log line format.
191
     *
192
     * @return string
193
     */
194
    final public function getLoggerFileFormat()
195
    {
196
        if ($this->file_format === null)
0 ignored issues
show
introduced by
The condition $this->file_format === null can never be true.
Loading history...
197
        {
198
            $this->file_format = "%t [%l] {%c:%f:%L} %p - %m";
199
        }
200
        return $this->file_format;
201
    }
202
203
    /**
204
     * {@inheritdoc}
205
     */
206
    final public function getLevel($log_level)
207
    {
208
        return self::$LEVEL_MAP[$log_level];
209
    }
210
211
    /**
212
     * {@inheritdoc}
213
     */
214
    final public function getColours($log_level)
215
    {
216
        return self::$LEVEL_COLOUR_MAP[$log_level];
217
    }
218
219
}
220