Completed
Pull Request — master (#71)
by Robbie
01:45
created

ReverseNullHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isHandling() 0 4 1
A handle() 0 9 2
1
<?php
2
3
namespace LeKoala\DebugBar\Messages;
4
5
use Monolog\Handler\AbstractHandler;
6
use Monolog\Logger;
7
8
class ReverseNullHandler extends AbstractHandler
9
{
10
    public function __construct($level = Logger::ERROR)
11
    {
12
        parent::__construct($level, false);
13
    }
14
15
    /**
16
     * Reverse the handling logic so that records will be handled up until the
17
     * provided level, rather than for any log level above it
18
     *
19
     * {@inheritDoc}
20
     */
21
    public function isHandling(array $record)
22
    {
23
        return $record['level'] < $this->level;
24
    }
25
26
    public function handle(array $record)
27
    {
28
        // d($record);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
29
        if ($record['level'] >= $this->level) {
30
            return false;
31
        }
32
33
        return true;
34
    }
35
}
36