]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / vendor / monolog / monolog / src / Monolog / Handler / HandlerWrapper.php
1 <?php
2
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Monolog\Handler;
13
14 use Monolog\Formatter\FormatterInterface;
15
16 /**
17  * This simple wrapper class can be used to extend handlers functionality.
18  *
19  * Example: A filtering handle. Inherit from this class, override isHandling() like this
20  *
21  * public function isHandling(array $record)
22  * {
23  *      if ($record meets certain conditions) {
24  *          return false;
25  *      }
26  *      return $this->handler->isHandling($record);
27  * }
28  *
29  * @author Alexey Karapetov <alexey@karapetov.com>
30  */
31 class HandlerWrapper implements HandlerInterface
32 {
33     /**
34      * @var HandlerInterface
35      */
36     protected $handler;
37
38     /**
39      * HandlerWrapper constructor.
40      * @param HandlerInterface $handler
41      */
42     public function __construct(HandlerInterface $handler)
43     {
44         $this->handler = $handler;
45     }
46
47     /**
48      * {@inheritdoc}
49      */
50     public function isHandling(array $record)
51     {
52         return $this->handler->isHandling($record);
53     }
54
55     /**
56      * {@inheritdoc}
57      */
58     public function handle(array $record)
59     {
60         return $this->handler->handle($record);
61     }
62
63     /**
64      * {@inheritdoc}
65      */
66     public function handleBatch(array $records)
67     {
68         return $this->handler->handleBatch($records);
69     }
70
71     /**
72      * {@inheritdoc}
73      */
74     public function pushProcessor($callback)
75     {
76         $this->handler->pushProcessor($callback);
77
78         return $this;
79     }
80
81     /**
82      * {@inheritdoc}
83      */
84     public function popProcessor()
85     {
86         return $this->handler->popProcessor();
87     }
88
89     /**
90      * {@inheritdoc}
91      */
92     public function setFormatter(FormatterInterface $formatter)
93     {
94         $this->handler->setFormatter($formatter);
95
96         return $this;
97     }
98
99     /**
100      * {@inheritdoc}
101      */
102     public function getFormatter()
103     {
104         return $this->handler->getFormatter();
105     }
106 }