7
7
* @copyright 2020 Joshua Parker <[email protected] >
8
8
* @copyright 2016 Sinergi
9
9
* @license https://opensource.org/licenses/mit-license.php MIT License
10
- *
11
- * @since 1.0.0
12
10
*/
13
11
14
12
declare (strict_types=1 );
@@ -39,15 +37,16 @@ public static function factory($config): Collection
39
37
/**
40
38
* Set a config
41
39
*
42
- * @param array $config
43
- * @return void|self
40
+ * @param string $key
41
+ * @param mixed $value
42
+ * @return self
44
43
*/
45
- public function setConfigKey (string $ key , $ config )
44
+ public function setConfigKey (string $ key , mixed $ value ): static
46
45
{
47
46
if (! isset ($ this ->container [$ key ])) {
48
- $ this ->container [$ key ] = $ config ;
47
+ $ this ->container [$ key ] = $ value ;
49
48
} else {
50
- $ this ->container [$ key ] = array_merge ($ this ->container [$ key ], $ config );
49
+ $ this ->container [$ key ] = array_merge ($ this ->container [$ key ], $ value );
51
50
}
52
51
return $ this ;
53
52
}
@@ -68,16 +67,16 @@ public function removeConfigKey(string $key): void
68
67
/**
69
68
* Get a config
70
69
*
71
- * @param mixed $default
72
- * @throws TypeException
70
+ * @param string $key
71
+ * @param mixed|null $default
73
72
* @return mixed
73
+ * @throws TypeException
74
74
*/
75
- public function getConfigKey (string $ key , $ default = null ): mixed
75
+ public function getConfigKey (string $ key , mixed $ default = null ): mixed
76
76
{
77
77
if (! is_string ($ key ) || empty ($ key )) {
78
78
throw new TypeException (
79
- sprintf ('Parameter %s passed to Config::get() is not a valid string resource. ' ),
80
- $ key
79
+ sprintf ('Parameter %s passed to Config::get() is not a valid string resource. ' , $ key ),
81
80
);
82
81
}
83
82
@@ -97,7 +96,7 @@ public function getConfigKey(string $key, $default = null): mixed
97
96
/**
98
97
* @return $this
99
98
*/
100
- public function reset ()
99
+ public function reset (): static
101
100
{
102
101
$ this ->container = [];
103
102
return $ this ;
@@ -106,33 +105,38 @@ public function reset()
106
105
/**
107
106
* @param string $key
108
107
* @return mixed
108
+ * @throws TypeException
109
109
*/
110
110
public function __get ($ key )
111
111
{
112
112
return $ this ->offsetGet ($ key );
113
113
}
114
114
115
115
/**
116
- * @param string $key
116
+ * @param mixed $key
117
117
* @param array|null $args
118
118
* @return mixed
119
+ * @throws TypeException
119
120
*/
120
- public function __call ($ key , $ args = null )
121
+ public function __call (mixed $ key , array $ args = null )
121
122
{
122
123
return $ this ->offsetGet ($ key );
123
124
}
124
125
125
126
/**
126
- * @param string $key
127
+ * @param mixed $key
127
128
* @return bool
129
+ * @throws TypeException
128
130
*/
129
- public function __isset ($ key )
131
+ public function __isset (mixed $ key )
130
132
{
131
133
return $ this ->offsetExists ($ key );
132
134
}
133
135
134
136
/**
135
137
* @param mixed $offset
138
+ * @return bool
139
+ * @throws TypeException
136
140
*/
137
141
public function offsetExists (mixed $ offset ): bool
138
142
{
@@ -143,6 +147,7 @@ public function offsetExists(mixed $offset): bool
143
147
/**
144
148
* @param mixed $offset
145
149
* @return mixed
150
+ * @throws TypeException
146
151
*/
147
152
public function offsetGet (mixed $ offset ): mixed
148
153
{
0 commit comments