Completed
Push — master ( f4415a...651f7b )
by Anton
12s
created

Logger::initInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Proxy;
12
13
use Bluz\Common\Nil;
14
use Bluz\Logger\Logger as Instance;
15
16
/**
17
 * Proxy to Logger
18
 *
19
 * Example of usage
20
 * <code>
21
 *     use Bluz\Proxy\Logger;
22
 *
23
 *     Logger::error('Configuration not found');
24
 * </code>
25
 *
26
 * @package  Bluz\Proxy
27
 * @author   Anton Shevchuk
28
 *
29
 * @method   static Instance getInstance()
30
 *
31
 * @method   static void alert($message, array $context = [])
32
 * @see      Instance::alert()
33
 *
34
 * @method   static void critical($message, array $context = [])
35
 * @see      Instance::critical()
36
 *
37
 * @method   static void debug($message, array $context = [])
38
 * @see      Instance::debug()
39
 *
40
 * @method   static void emergency($message, array $context = [])
41
 * @see      Instance::emergency()
42
 *
43
 * @method   static void error($message, array $context = [])
44
 * @see      Instance::error()
45
 *
46
 * @method   static void info($message, array $context = [])
47
 * @see      Instance::info()
48
 *
49
 * @method   static void notice($message, array $context = [])
50
 * @see      Instance::notice()
51
 *
52
 * @method   static void warning($message, array $context = [])
53
 * @see      Instance::warning()
54
 *
55
 * @method   static void log($level, $message, array $context = [])
56
 * @see      Instance::log()
57
 *
58
 * @method   static array get($level)
59
 * @see      Instance::get()
60
 */
61
final class Logger
62
{
63
    use ProxyTrait;
64
65
    /**
66
     * Init instance
67
     *
68
     * @return Instance|Nil
69
     */
70 604
    private static function initInstance()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
71
    {
72 604
        if (Config::get('logger')) {
73 604
            return new Instance();
74
        }
75
        return new Nil();
76
    }
77
78
    /**
79
     * exception
80
     *
81
     * @param \Exception $exception
82
     *
83
     * @return void
84
     */
85 2
    public static function exception($exception)
86
    {
87 2
        self::getInstance()->error(
88 2
            $exception->getMessage() . ' [' .
89 2
            $exception->getFile() . ':' .
90 2
            $exception->getLine() . ']'
91
        );
92 2
    }
93
}
94