PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / monolog / monolog / src / Monolog / Handler / FormattableHandlerTrait.php

FormattableHandlerTrait.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 4.7.0, at vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php

61 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <[email protected]>
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 use Monolog\Formatter\LineFormatter;
16
17 /**
18 * Helper trait for implementing FormattableInterface
19 *
20 * @author Jordi Boggiano <[email protected]>
21 */
22 trait FormattableHandlerTrait
23 {
24 /**
25 * @var ?FormatterInterface
26 */
27 protected $formatter;
28
29 /**
30 * {@inheritDoc}
31 */
32 public function setFormatter(FormatterInterface $formatter): HandlerInterface
33 {
34 $this->formatter = $formatter;
35
36 return $this;
37 }
38
39 /**
40 * {@inheritDoc}
41 */
42 public function getFormatter(): FormatterInterface
43 {
44 if (!$this->formatter) {
45 $this->formatter = $this->getDefaultFormatter();
46 }
47
48 return $this->formatter;
49 }
50
51 /**
52 * Gets the default formatter.
53 *
54 * Overwrite this if the LineFormatter is not a good default for your handler.
55 */
56 protected function getDefaultFormatter(): FormatterInterface
57 {
58 return new LineFormatter();
59 }
60 }
61