Completed
Push — master ( 265a2d...f9e310 )
by jerome
02:58
created

DebugOnlyHandler::getFormatter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace DP\Core\CoreBundle\Monolog;
4
5
use Monolog\Formatter\FormatterInterface;
6
use Monolog\Handler\HandlerInterface;
7
8
class DebugOnlyHandler implements HandlerInterface
9
{
10
    /**
11
     * @var HandlerInterface
12
     */
13
    private $handler;
14
15
    /**
16
     * @var bool
17
     */
18
    private $debug;
19
20
    /**
21
     * @param HandlerInterface $handler
22
     * @param bool             $debug
23
     */
24
    public function __construct(HandlerInterface $handler, $debug)
25
    {
26
        $this->handler = $handler;
27
        $this->debug   = $debug;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function isHandling(array $record)
34
    {
35
        if (false === $this->debug) {
36
            return false;
37
        }
38
39
        return $this->handler->isHandling($record);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function handle(array $record)
46
    {
47
        if (false === $this->debug) {
48
            return false;
49
        }
50
51
        return $this->handler->handle($record);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function handleBatch(array $records)
58
    {
59
        if (false === $this->debug) {
60
            return;
61
        }
62
63
        $this->handler->handleBatch($records);
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function pushProcessor($callback)
70
    {
71
        $this->handler->pushProcessor($callback);
72
73
        return $this;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function popProcessor()
80
    {
81
        return $this->handler->popProcessor();
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function setFormatter(FormatterInterface $formatter)
88
    {
89
        $this->handler->setFormatter($formatter);
90
91
        return $this;
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function getFormatter()
98
    {
99
        return $this->handler->getFormatter();
100
    }
101
}
102