PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.21
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.21
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 1.10.1 All 168 releases
woocommerce-pos / vendor / mustache / mustache / src / Source / FilesystemSource.php

FilesystemSource.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.21, at vendor/mustache/mustache/src/Source/FilesystemSource.php

82 lines 1.9 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\Source;
13
14 use Mustache\Exception\RuntimeException;
15 use Mustache\Source;
16
17 /**
18 * Mustache template Filesystem Source.
19 *
20 * This template Source uses stat() to generate the Source key, so that using
21 * pre-compiled templates doesn't require hitting the disk to read the source.
22 * It is more suitable for production use, and is used by default in the
23 * ProductionFilesystemLoader.
24 */
25 class FilesystemSource implements Source
26 {
27 private $fileName;
28 private $statProps;
29 private $stat;
30
31 /**
32 * Filesystem Source constructor.
33 *
34 * @param string $fileName
35 */
36 public function __construct($fileName, array $statProps)
37 {
38 $this->fileName = $fileName;
39 $this->statProps = $statProps;
40 }
41
42 /**
43 * Get the Source key (used to generate the compiled class name).
44 *
45 * @throws RuntimeException when a source file cannot be read
46 *
47 * @return string
48 */
49 public function getKey()
50 {
51 $chunks = [
52 'fileName' => $this->fileName,
53 ];
54
55 if (!empty($this->statProps)) {
56 if (!isset($this->stat)) {
57 $this->stat = @stat($this->fileName);
58 }
59
60 if ($this->stat === false) {
61 throw new RuntimeException(sprintf('Failed to read source file "%s".', $this->fileName));
62 }
63
64 foreach ($this->statProps as $prop) {
65 $chunks[$prop] = $this->stat[$prop];
66 }
67 }
68
69 return json_encode($chunks);
70 }
71
72 /**
73 * Get the template Source.
74 *
75 * @return string
76 */
77 public function getSource()
78 {
79 return file_get_contents($this->fileName);
80 }
81 }
82