diff options
Diffstat (limited to 'src/Monolog/Handler/MailHandler.php')
-rw-r--r-- | src/Monolog/Handler/MailHandler.php | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/Monolog/Handler/MailHandler.php b/src/Monolog/Handler/MailHandler.php index 9e23283..634fbc1 100644 --- a/src/Monolog/Handler/MailHandler.php +++ b/src/Monolog/Handler/MailHandler.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,6 +11,9 @@ namespace Monolog\Handler; +use Monolog\Formatter\FormatterInterface; +use Monolog\Formatter\HtmlFormatter; + /** * Base class for all mail handlers * @@ -23,7 +26,7 @@ abstract class MailHandler extends AbstractProcessingHandler */ public function handleBatch(array $records) { - $messages = array(); + $messages = []; foreach ($records as $record) { if ($record['level'] < $this->level) { @@ -43,14 +46,14 @@ abstract class MailHandler extends AbstractProcessingHandler * @param string $content formatted email body to be sent * @param array $records the array of log records that formed this content */ - abstract protected function send($content, array $records); + abstract protected function send(string $content, array $records); /** * {@inheritdoc} */ protected function write(array $record) { - $this->send((string) $record['formatted'], array($record)); + $this->send((string) $record['formatted'], [$record]); } protected function getHighestRecord(array $records) @@ -64,4 +67,19 @@ abstract class MailHandler extends AbstractProcessingHandler return $highestRecord; } + + protected function isHtmlBody($body) + { + return substr($body, 0, 1) === '<'; + } + + /** + * Gets the default formatter. + * + * @return FormatterInterface + */ + protected function getDefaultFormatter(): FormatterInterface + { + return new HtmlFormatter(); + } } |