PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
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 6.3.0, at src/extra/php-codesniffer-php-token/Util/Cache.php

92 lines 1.7 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 class Cache {
13
14 /**
15 * The filesystem location of the cache file.
16 *
17 * @var void
18 */
19 private static $path = '';
20
21 /**
22 * The cached data.
23 *
24 * @var array<string, mixed>
25 */
26 private static $cache = [];
27
28 /**
29 * Saves the current cache to the filesystem.
30 *
31 * @return void
32 */
33 public static function save() {
34 file_put_contents( self::$path, json_encode( self::$cache ) );
35
36 }//end save()
37
38
39 /**
40 * Retrieves a single entry from the cache.
41 *
42 * @param string $key The key of the data to get. If NULL,
43 * everything in the cache is returned.
44 *
45 * @return mixed
46 */
47 public static function get( $key = null ) {
48 if ( $key === null ) {
49 return self::$cache;
50 }
51
52 if ( isset( self::$cache[ $key ] ) === true ) {
53 return self::$cache[ $key ];
54 }
55
56 return false;
57
58 }//end get()
59
60
61 /**
62 * Retrieves a single entry from the cache.
63 *
64 * @param string $key The key of the data to set. If NULL,
65 * sets the entire cache.
66 * @param mixed $value The value to set.
67 *
68 * @return void
69 */
70 public static function set( $key, $value ) {
71 if ( $key === null ) {
72 self::$cache = $value;
73 } else {
74 self::$cache[ $key ] = $value;
75 }
76
77 }//end set()
78
79
80 /**
81 * Retrieves the number of cache entries.
82 *
83 * @return int
84 */
85 public static function getSize() {
86 return ( count( self::$cache ) - 1 );
87
88 }//end getSize()
89
90
91 }//end class
92