PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.1.9
Responsive Menu – Create Mobile-Friendly Menu v3.1.9
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / app / Container / Container.php

Container.php in Responsive Menu – Create Mobile-Friendly Menu 3.1.9, at app/Container/Container.php

48 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ResponsiveMenu\Container;
4
5 class Container implements \ArrayAccess {
6
7 private $values = [];
8 private $raw = [];
9 private $keys = [];
10
11 public function offsetSet($id, $value) {
12 $this->values[$id] = $value;
13 $this->keys[$id] = true;
14 }
15
16 public function offsetGet($id) {
17
18 if(!isset($this->keys[$id])) {
19 throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
20 }
21
22 if(isset($this->raw[$id]) || !is_object($this->values[$id]) || !method_exists($this->values[$id], '__invoke')) {
23 return $this->values[$id];
24 }
25
26 $raw = $this->values[$id];
27 $val = $this->values[$id] = $raw($this);
28 $this->raw[$id] = $this->values[$id];
29
30 return $this->values[$id];
31 }
32
33 public function offsetExists($id) {
34 return isset($this->keys[$id]);
35 }
36
37 public function offsetUnset($id) {
38 if(isset($this->keys[$id])) {
39 unset($this->values[$id], $this->raw[$id], $this->keys[$id]);
40 }
41 }
42
43 public function keys() {
44 return array_keys($this->values);
45 }
46
47 }
48