PluginProbe ʕ •ᴥ•ʔ
Loco Translate / 2.8.0
Loco Translate v2.8.0
2.8.5 2.8.4 2.5.8 2.6.0 2.6.1 2.6.10 2.6.11 2.6.12 2.6.13 2.6.14 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0 2.8.1 2.8.2 2.8.3 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2 1.2.1 1.2.2 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7
loco-translate / src / data / CompiledData.php
loco-translate / src / data Last commit date
CompiledData.php 3 years ago Cookie.php 4 years ago Option.php 9 years ago Permissions.php 1 year ago Preferences.php 4 years ago RecentItems.php 2 years ago Serializable.php 3 years ago Session.php 4 years ago Settings.php 1 year ago Transient.php 7 years ago Upload.php 2 years ago
CompiledData.php
94 lines
1 <?php
2 /**
3 * Static, read-only caching of data held in serialized files.
4 * Used for pre-built arrays of information such as plural forms.
5 */
6 class Loco_data_CompiledData implements ArrayAccess, Countable, IteratorAggregate {
7
8 /**
9 * @var array
10 */
11 private static $reg = [];
12
13 /**
14 * @var string
15 */
16 private $name;
17
18 /**
19 * @var array
20 */
21 private $data;
22
23
24 /**
25 * @param string $name
26 * @return self
27 */
28 public static function get( $name ){
29 if( ! isset(self::$reg[$name]) ){
30 self::$reg[$name] = new Loco_data_CompiledData($name);
31 }
32 return self::$reg[$name];
33 }
34
35
36 /**
37 * Remove all cached data from memory
38 * @return void
39 */
40 public static function flush(){
41 self::$reg = [];
42 }
43
44
45 private function __construct( $name ){
46 $path = 'lib/data/'.$name.'.php';
47 $this->data = loco_include( $path );
48 $this->name = $name;
49 }
50
51
52 public function destroy(){
53 unset( self::$reg[$this->name], $this->data );
54 }
55
56
57 #[ReturnTypeWillChange]
58 public function offsetGet( $k ){
59 return isset($this->data[$k]) ? $this->data[$k] : null;
60 }
61
62
63 #[ReturnTypeWillChange]
64 public function offsetExists( $k ){
65 return isset($this->data[$k]);
66 }
67
68
69 #[ReturnTypeWillChange]
70 public function offsetUnset( $k ){
71 throw new RuntimeException('Read only');
72 }
73
74
75 #[ReturnTypeWillChange]
76 public function offsetSet( $k, $v ){
77 throw new RuntimeException('Read only');
78 }
79
80 #[ReturnTypeWillChange]
81 public function count(){
82 return count($this->data);
83 }
84
85 /**
86 * Implements IteratorAggregate::getIterator
87 * @return ArrayIterator
88 */
89 #[ReturnTypeWillChange]
90 public function getIterator(){
91 return new ArrayIterator( $this->data );
92 }
93
94 }