PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / extra / php-codesniffer-php-token / Util / Cache.php

Cache.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at src/extra/php-codesniffer-php-token/Util/Cache.php

101 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Function for caching between runs.
4 *
5 * @author Greg Sherwood <[email protected]>
6 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8 */
9
10 namespace PHP_CodeSniffer\Util;
11
12 use PHP_CodeSniffer\Autoload;
13 use PHP_CodeSniffer\Config;
14 use PHP_CodeSniffer\Ruleset;
15
16 class Cache
17 {
18
19 /**
20 * The filesystem location of the cache file.
21 *
22 * @var void
23 */
24 private static $path = '';
25
26 /**
27 * The cached data.
28 *
29 * @var array<string, mixed>
30 */
31 private static $cache = [];
32
33 /**
34 * Saves the current cache to the filesystem.
35 *
36 * @return void
37 */
38 public static function save()
39 {
40 file_put_contents(self::$path, json_encode(self::$cache));
41
42 }//end save()
43
44
45 /**
46 * Retrieves a single entry from the cache.
47 *
48 * @param string $key The key of the data to get. If NULL,
49 * everything in the cache is returned.
50 *
51 * @return mixed
52 */
53 public static function get($key=null)
54 {
55 if ($key === null) {
56 return self::$cache;
57 }
58
59 if (isset(self::$cache[$key]) === true) {
60 return self::$cache[$key];
61 }
62
63 return false;
64
65 }//end get()
66
67
68 /**
69 * Retrieves a single entry from the cache.
70 *
71 * @param string $key The key of the data to set. If NULL,
72 * sets the entire cache.
73 * @param mixed $value The value to set.
74 *
75 * @return void
76 */
77 public static function set($key, $value)
78 {
79 if ($key === null) {
80 self::$cache = $value;
81 } else {
82 self::$cache[$key] = $value;
83 }
84
85 }//end set()
86
87
88 /**
89 * Retrieves the number of cache entries.
90 *
91 * @return int
92 */
93 public static function getSize()
94 {
95 return (count(self::$cache) - 1);
96
97 }//end getSize()
98
99
100 }//end class
101