Monolog   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 5
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A log() 0 4 1
A write() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arnaud
5
 * Date: 04/11/15
6
 * Time: 20:13
7
 */
8
9
namespace Ndrx\Profiler\Components\Logs;
10
11
use Monolog\Handler\AbstractProcessingHandler;
12
use Ndrx\Profiler\Events\DispatcherAwareInterface;
13
use Ndrx\Profiler\Events\DispatcherAwareTrait;
14
use Ndrx\Profiler\Events\Log;
15
use Psr\Log\LoggerInterface;
16
use Psr\Log\LoggerTrait;
17
18
class Monolog extends AbstractProcessingHandler implements DispatcherAwareInterface, LoggerInterface
19
{
20
    use DispatcherAwareTrait, LoggerTrait;
21
22
    /**
23
     * Logs with an arbitrary level.
24
     *
25
     * @param mixed $level
26
     * @param string $message
27
     * @param array $context
28
     * @return null
29
     */
30 2
    public function log($level, $message, array $context = array())
31
    {
32 2
        $this->dispatcher->dispatch(Log::EVENT_NAME, new Log($level, $message, $context, []));
33 2
    }
34
35
    /**
36
     * Writes the record down to the log of the implementing handler
37
     *
38
     * @param  array $record
39
     * @return void
40
     */
41 2
    protected function write(array $record)
42
    {
43 2
        $this->log($record['level'], $record['message']);
44 2
    }
45
}
46