Skip to content

Commit fe6a8eb

Browse files
committed
Systemparser fix to static setter and getter
1 parent d6b48b9 commit fe6a8eb

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/Envparser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ public function checkSystemVar($variable)
150150

151151
public function getSystemVars($variable = null)
152152
{
153-
return $this->systemparser->getValues($variable);
153+
$systemparse = $this->systemparser;
154+
return $systemparse::getValues($variable);
154155
}
155156

156157
public function run()

src/Parser/SystemParser.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ public function __construct()
1717

1818
public function parse()
1919
{
20-
if (function_exists('getenv')) {
21-
return getenv();
20+
if (!empty($_ENV)) {
21+
return $_ENV;
2222
}
2323

24-
if (is_array($_ENV)) {
25-
return $_ENV;
24+
if (function_exists('getenv')) {
25+
return getenv();
2626
}
2727
}
2828

29-
public function getValues($variable = null)
29+
public static function getValues($variable = null)
3030
{
3131
if (!is_null($variable)) {
3232
if (isset(self::$sysvar[$variable])) {
@@ -36,15 +36,20 @@ public function getValues($variable = null)
3636
}
3737
}
3838

39-
return self::$sysvar;
39+
return static::getAllEnvVariables();
4040
}
4141

42-
public function checkValue($variable)
42+
public static function checkValue($variable)
4343
{
4444
if (isset(self::$sysvar[$variable])) {
4545
return true;
4646
}
4747

4848
return false;
4949
}
50+
51+
private static function getAllEnvVariables()
52+
{
53+
return static::$sysvar;
54+
}
5055
}

0 commit comments

Comments
 (0)