# worker/4.0.1/src/Dropbox/ArrayEntryStore.php

ManageWP Worker, version 4.0.1. 61 lines.

- Page: https://pluginprobe.com/plugins/worker/4.0.1/code/src/Dropbox/ArrayEntryStore.php
- Raw: https://pluginprobe.com/plugins/worker/4.0.1/raw/src/Dropbox/ArrayEntryStore.php
- Modified: 2015-01-18T15:26:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/worker/4.0.1/code/src/Dropbox/ArrayEntryStore.php#L10-L20`.

```php
<?php

/**
 * A class that gives get/put/clear access to a single entry in an array.
 */
class Dropbox_ArrayEntryStore implements Dropbox_ValueStore
{
    /** @var array */
    private $array;

    /** @var mixed */
    private $key;

    /**
     * Constructor.
     *
     * @param array $array
     *                     The array that we'll be accessing.
     *
     * @param mixed $key
     *                   The key for the array element we'll be accessing.
     */
    public function __construct(&$array, $key)
    {
        $this->array = &$array;
        $this->key   = $key;
    }

    /**
     * Returns the entry's current value or <code>null</code> if nothing is set.
     *
     * @return object
     */
    public function get()
    {
        if (isset($this->array[$this->key])) {
            return $this->array[$this->key];
        } else {
            return null;
        }
    }

    /**
     * Set the array entry to the given value.
     *
     * @param object $value
     */
    public function set($value)
    {
        $this->array[$this->key] = $value;
    }

    /**
     * Clear the entry.
     */
    public function clear()
    {
        unset($this->array[$this->key]);
    }
}

```
