PluginProbe
ManageWP Worker / 4.0.1
ManageWP Worker v4.0.1
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / Dropbox / ArrayEntryStore.php

ArrayEntryStore.php in ManageWP Worker 4.0.1, at src/Dropbox/ArrayEntryStore.php

61 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * A class that gives get/put/clear access to a single entry in an array.
5 */
6 class Dropbox_ArrayEntryStore implements Dropbox_ValueStore
7 {
8 /** @var array */
9 private $array;
10
11 /** @var mixed */
12 private $key;
13
14 /**
15 * Constructor.
16 *
17 * @param array $array
18 * The array that we'll be accessing.
19 *
20 * @param mixed $key
21 * The key for the array element we'll be accessing.
22 */
23 public function __construct(&$array, $key)
24 {
25 $this->array = &$array;
26 $this->key = $key;
27 }
28
29 /**
30 * Returns the entry's current value or <code>null</code> if nothing is set.
31 *
32 * @return object
33 */
34 public function get()
35 {
36 if (isset($this->array[$this->key])) {
37 return $this->array[$this->key];
38 } else {
39 return null;
40 }
41 }
42
43 /**
44 * Set the array entry to the given value.
45 *
46 * @param object $value
47 */
48 public function set($value)
49 {
50 $this->array[$this->key] = $value;
51 }
52
53 /**
54 * Clear the entry.
55 */
56 public function clear()
57 {
58 unset($this->array[$this->key]);
59 }
60 }
61