Passed
Push — master ( a6375b...78beea )
by Anton
05:54
created

Logger::exception()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
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 602
    private static function initInstance()
0 ignored issues
show
Unused Code introduced by
The method initInstance() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
71
    {
72 602
        if (Config::get('logger')) {
73 602
            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): void
86
    {
87 2
        self::getInstance()->error(
88 2
            $exception->getMessage() . ' [' .
89 2
            $exception->getFile() . ':' .
90 2
            $exception->getLine() . ']'
91
        );
92 2
    }
93
}
94