PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.25
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.25
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
woocommerce-pos / vendor / mustache / mustache / src / Cache / AbstractCache.php

AbstractCache.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.25, at vendor/mustache/mustache/src/Cache/AbstractCache.php

69 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Mustache.php.
5 *
6 * (c) 2010-2026 Justin Hileman
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 Mustache\Cache;
13
14 use Mustache\Cache;
15 use Mustache\Exception\InvalidArgumentException;
16 use Mustache\Logger;
17 use Psr\Log\LoggerInterface;
18
19 /**
20 * Abstract Mustache Cache class.
21 *
22 * Provides logging support to child implementations.
23 *
24 * @abstract
25 */
26 abstract class AbstractCache implements Cache
27 {
28 private $logger = null;
29
30 /**
31 * Get the current logger instance.
32 *
33 * @return Logger|LoggerInterface
34 */
35 public function getLogger()
36 {
37 return $this->logger;
38 }
39
40 /**
41 * Set a logger instance.
42 *
43 * @param Logger|LoggerInterface $logger
44 */
45 public function setLogger($logger = null)
46 {
47 // n.b. this uses `is_a` to prevent a dependency on Psr\Log
48 if ($logger !== null && !$logger instanceof Logger && !is_a($logger, 'Psr\\Log\\LoggerInterface')) {
49 throw new InvalidArgumentException('Expected an instance of Mustache\\Logger or Psr\\Log\\LoggerInterface.');
50 }
51
52 $this->logger = $logger;
53 }
54
55 /**
56 * Add a log record if logging is enabled.
57 *
58 * @param string $level The logging level
59 * @param string $message The log message
60 * @param array $context The log context
61 */
62 protected function log($level, $message, array $context = [])
63 {
64 if (isset($this->logger)) {
65 $this->logger->log($level, $message, $context);
66 }
67 }
68 }
69