44
55namespace Rancoud \Environment ;
66
7- /**
8- * Class Environment.
9- */
107class Environment
118{
129 public const int GETENV = 0x01 ;
@@ -47,15 +44,10 @@ class Environment
4744
4845 protected string $ endline = \PHP_EOL ;
4946
50- /**
51- * Environment constructor.
52- *
53- * @param array|string $folders
54- */
55- public function __construct ($ folders , string $ filename = '.env ' )
47+ public function __construct (array |string $ folders , string $ filename = '.env ' )
5648 {
5749 if (!\is_array ($ folders )) {
58- $ folders = [( string ) $ folders ];
50+ $ folders = [$ folders ];
5951 }
6052
6153 $ this ->folders = $ folders ;
@@ -228,8 +220,7 @@ protected function extractText(string $line): void
228220 }
229221 }
230222
231- /** @return bool|float|int|string|null */
232- protected function convertType (string $ value ): mixed
223+ protected function convertType (string $ value ): bool |float |int |string |null
233224 {
234225 $ val = \mb_strtolower ($ value );
235226 if ($ val === 'true ' ) {
@@ -269,7 +260,7 @@ protected function replaceVariables(string $value): string
269260 return $ value ;
270261 }
271262
272- protected function set (string $ key , $ value ): void
263+ protected function set (string $ key , mixed $ value ): void
273264 {
274265 $ this ->env [$ key ] = $ value ;
275266 }
@@ -287,11 +278,10 @@ protected function saveInCache(): void
287278 }
288279
289280 /**
290- * @param mixed|null $default
291281 * @throws EnvironmentException
292282 * @return mixed|null
293283 */
294- public function get (string $ key , $ default = null )
284+ public function get (string $ key , mixed $ default = null ): mixed
295285 {
296286 $ this ->autoload ();
297287
@@ -310,17 +300,13 @@ public function getAll(): array
310300 return $ this ->env ;
311301 }
312302
313- /**
314- * @param array|string $keys
315- *
316- * @throws EnvironmentException
317- */
318- public function exists ($ keys ): bool
303+ /** @throws EnvironmentException */
304+ public function exists (array |string $ keys ): bool
319305 {
320306 $ this ->autoload ();
321307
322308 if (!\is_array ($ keys )) {
323- $ keys = [( string ) $ keys ];
309+ $ keys = [$ keys ];
324310 }
325311
326312 foreach ($ keys as $ key ) {
0 commit comments