summaryrefslogtreecommitdiffstats
path: root/src/Monolog/Handler/HandlerWrapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Monolog/Handler/HandlerWrapper.php')
-rw-r--r--src/Monolog/Handler/HandlerWrapper.php50
1 files changed, 36 insertions, 14 deletions
diff --git a/src/Monolog/Handler/HandlerWrapper.php b/src/Monolog/Handler/HandlerWrapper.php
index e540d80..28fe57d 100644
--- a/src/Monolog/Handler/HandlerWrapper.php
+++ b/src/Monolog/Handler/HandlerWrapper.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
@@ -30,7 +30,7 @@ use Monolog\Formatter\FormatterInterface;
*
* @author Alexey Karapetov <alexey@karapetov.com>
*/
-class HandlerWrapper implements HandlerInterface
+class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface
{
/**
* @var HandlerInterface
@@ -49,7 +49,7 @@ class HandlerWrapper implements HandlerInterface
/**
* {@inheritdoc}
*/
- public function isHandling(array $record)
+ public function isHandling(array $record): bool
{
return $this->handler->isHandling($record);
}
@@ -57,7 +57,7 @@ class HandlerWrapper implements HandlerInterface
/**
* {@inheritdoc}
*/
- public function handle(array $record)
+ public function handle(array $record): bool
{
return $this->handler->handle($record);
}
@@ -73,36 +73,58 @@ class HandlerWrapper implements HandlerInterface
/**
* {@inheritdoc}
*/
- public function pushProcessor($callback)
+ public function close()
{
- $this->handler->pushProcessor($callback);
+ return $this->handler->close();
+ }
- return $this;
+ /**
+ * {@inheritdoc}
+ */
+ public function pushProcessor(callable $callback): HandlerInterface
+ {
+ if ($this->handler instanceof ProcessableHandlerInterface) {
+ $this->handler->pushProcessor($callback);
+
+ return $this;
+ }
+
+ throw new \LogicException('The wrapped handler does not implement ' . ProcessableHandlerInterface::class);
}
/**
* {@inheritdoc}
*/
- public function popProcessor()
+ public function popProcessor(): callable
{
- return $this->handler->popProcessor();
+ if ($this->handler instanceof ProcessableHandlerInterface) {
+ return $this->handler->popProcessor();
+ }
+
+ throw new \LogicException('The wrapped handler does not implement ' . ProcessableHandlerInterface::class);
}
/**
* {@inheritdoc}
*/
- public function setFormatter(FormatterInterface $formatter)
+ public function setFormatter(FormatterInterface $formatter): HandlerInterface
{
- $this->handler->setFormatter($formatter);
+ if ($this->handler instanceof FormattableHandlerInterface) {
+ $this->handler->setFormatter($formatter);
+ }
- return $this;
+ throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class);
}
/**
* {@inheritdoc}
*/
- public function getFormatter()
+ public function getFormatter(): FormatterInterface
{
- return $this->handler->getFormatter();
+ if ($this->handler instanceof FormattableHandlerInterface) {
+ return $this->handler->getFormatter($formatter);
+ }
+
+ throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class);
}
}