PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.14
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / framework / Config / Config.php

Config.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 4.3.14, at framework/Config/Config.php

142 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\Framework\Config;
4
5 use FluentForm\Framework\Helpers\ArrayHelper;
6
7 class Config implements \ArrayAccess
8 {
9 /**
10 * All array items from all files from /config directory
11 * @var array
12 */
13 protected $repository = array();
14
15 /**
16 * Initiate the instance
17 * @param array $repository
18 */
19 public function __construct($repository = array())
20 {
21 $this->repository = $repository;
22 }
23
24 /**
25 * Determine if the given configuration value exists.
26 *
27 * @param string $key
28 * @return bool
29 */
30 public function has($key)
31 {
32 return ArrayHelper::has($this->repository, $key);
33 }
34
35 /**
36 * Get all of the configuration items for the application.
37 *
38 * @return array
39 */
40 public function all()
41 {
42 return $this->repository;
43 }
44
45 /**
46 * Get the specified configuration value.
47 *
48 * @param array|string $key
49 * @param mixed $default
50 * @return mixed
51 */
52 public function get($key = null, $default = null)
53 {
54 return ArrayHelper::get($this->repository, $key, $default);
55 }
56
57 /**
58 * Set a given configuration value.
59 *
60 * @param array|string $key
61 * @param mixed $value
62 * @return void
63 */
64 public function set($key, $value)
65 {
66 $keys = is_array($key) ? $key : [$key => $value];
67
68 foreach ($keys as $key => $value) {
69 return ArrayHelper::set($this->repository, $key, $value);
70 }
71 }
72
73 /**
74 * Dynamic Getter
75 * @param string $key
76 * @return mixed
77 */
78 public function __get($key = null)
79 {
80 return $this->get($key);
81 }
82
83 /**
84 * Dynamic Setter
85 * @param string $key
86 * @param mixed $key
87 * @return void
88 */
89 public function __set($key, $value)
90 {
91 return $this->set($key, $value);
92 }
93
94 /**
95 * Determine if the given item exists.
96 *
97 * @param string $key
98 * @return bool
99 */
100 #[\ReturnTypeWillChange]
101 public function offsetExists($key)
102 {
103 return $this->has($key);
104 }
105
106 /**
107 * Get an item.
108 *
109 * @param string $key
110 * @return mixed
111 */
112 #[\ReturnTypeWillChange]
113 public function offsetGet($key)
114 {
115 return $this->get($key);
116 }
117
118 /**
119 * Set an item.
120 *
121 * @param string $key
122 * @param mixed $value
123 * @return void
124 */
125 #[\ReturnTypeWillChange]
126 public function offsetSet($key, $value)
127 {
128 $this->set($key, $value);
129 }
130
131 /**
132 * Unset an item.
133 *
134 * @param string $key
135 * @return void
136 */
137 #[\ReturnTypeWillChange]
138 public function offsetUnset($key)
139 {
140 $this->set($key, null);
141 }
142 }