Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console-core / src / Utils / KeyValueStorage.php
diff --git a/vendor/drupal/console-core/src/Utils/KeyValueStorage.php b/vendor/drupal/console-core/src/Utils/KeyValueStorage.php
new file mode 100644 (file)
index 0000000..d8ef7a3
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+
+namespace Drupal\Console\Core\Utils;
+
+
+class KeyValueStorage
+{
+
+    /**
+     * @var array
+     */
+    protected $data = [];
+
+    /**
+     * Checks if the container has the given key.
+     *
+     * @param  string $key
+     *   The key to check.
+     *
+     * @return boolean
+     */
+    public function has($key)
+    {
+        return array_key_exists($key, $this->data);
+    }
+
+    /**
+     * Gets the given key from the container, or returns the default if it does
+     * not exist.
+     *
+     * @param  string $key
+     *   The key to get.
+     * @param  mixed $default
+     *   Default value to return.
+     *
+     * @return mixed
+     */
+    public function get($key, $default = null)
+    {
+        return $this->has($key) ? $this->data[$key] : $default;
+    }
+
+    /**
+     * Sets the given key in the container.
+     *
+     * @param mixed $key
+     *   The key to set
+     * @param mixed $value
+     *   The value.
+     */
+    public function set($key, $value = null)
+    {
+        $this->data[$key] = $value;
+    }
+
+    /**
+     * Removes the given key from the container.
+     *
+     * @param  string $key The key to forget.
+     *
+     * @return void
+     */
+    public function remove($key)
+    {
+        unset($this->data[$key]);
+    }
+
+}