Skip to content

Commit d25b56b

Browse files
committed
Move get method to DefaultEnvironment.
1 parent 593c465 commit d25b56b

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/Environment.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
/**
66
* Helpers for working with the Drupal environment.
77
*
8-
* @todo Add Platform.sh support
9-
*
8+
* @method static mixed get(string $name)
109
* @method static string getEnvironment()
1110
* @method static bool isAcquia()
1211
* @method static bool isPantheon()
@@ -52,7 +51,7 @@ public static function getEnvironmentClass()
5251
// Intentionally re-assigning the class variable here so that a match
5352
// breaks the foreach loop, or we fall back to the default class.
5453
foreach (static::CLASSES as $class) {
55-
if (static::get($class::ENVIRONMENT_NAME)) {
54+
if (getenv($class::ENVIRONMENT_NAME)) {
5655
break;
5756
}
5857
}
@@ -76,24 +75,6 @@ public static function __callStatic(string $name, array $arguments)
7675
return $class::$name(...$arguments);
7776
}
7877

79-
/**
80-
* Get an environment variable.
81-
*
82-
* @param string $name
83-
* The name of the environment variable to retrieve.
84-
*
85-
* @return mixed
86-
* The environment variable, if it's set.
87-
*/
88-
public static function get(string $name)
89-
{
90-
static $cache = [];
91-
if (!array_key_exists($name, $cache)) {
92-
$cache[$name] = getenv($name);
93-
}
94-
return $cache[$name];
95-
}
96-
9778
/**
9879
* Determine if this is a local environment.
9980
*

src/Environment/DefaultEnvironment.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ class DefaultEnvironment
4343
*/
4444
public const CI = 'ci';
4545

46+
/**
47+
* Get an environment variable.
48+
*
49+
* @param string $name
50+
* The name of the environment variable to retrieve.
51+
*
52+
* @return mixed
53+
* The environment variable, if it's set.
54+
*/
55+
public static function get(string $name)
56+
{
57+
static $cache = [];
58+
if (!array_key_exists($name, $cache)) {
59+
$cache[$name] = getenv($name);
60+
}
61+
return $cache[$name];
62+
}
63+
4664
/**
4765
* Return the environment name.
4866
*

0 commit comments

Comments
 (0)