Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / drupal / console-core / src / Utils / KeyValueStorage.php
1 <?php
2
3
4 namespace Drupal\Console\Core\Utils;
5
6
7 class KeyValueStorage
8 {
9
10     /**
11      * @var array
12      */
13     protected $data = [];
14
15     /**
16      * Checks if the container has the given key.
17      *
18      * @param  string $key
19      *   The key to check.
20      *
21      * @return boolean
22      */
23     public function has($key)
24     {
25         return array_key_exists($key, $this->data);
26     }
27
28     /**
29      * Gets the given key from the container, or returns the default if it does
30      * not exist.
31      *
32      * @param  string $key
33      *   The key to get.
34      * @param  mixed $default
35      *   Default value to return.
36      *
37      * @return mixed
38      */
39     public function get($key, $default = null)
40     {
41         return $this->has($key) ? $this->data[$key] : $default;
42     }
43
44     /**
45      * Sets the given key in the container.
46      *
47      * @param mixed $key
48      *   The key to set
49      * @param mixed $value
50      *   The value.
51      */
52     public function set($key, $value = null)
53     {
54         $this->data[$key] = $value;
55     }
56
57     /**
58      * Removes the given key from the container.
59      *
60      * @param  string $key The key to forget.
61      *
62      * @return void
63      */
64     public function remove($key)
65     {
66         unset($this->data[$key]);
67     }
68
69 }