blob: 453f98e39738fe658bc37800c69286f23076cc20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Common\Configuration\Resolver;
use OpenTelemetry\SDK\Common\Configuration\Configuration;
/**
* @internal
*/
class EnvironmentResolver implements ResolverInterface
{
public function hasVariable(string $variableName): bool
{
if (!Configuration::isEmpty($_SERVER[$variableName] ?? null)) {
return true;
}
$env = getenv($variableName);
if ($env === false) {
return false;
}
return !Configuration::isEmpty($env);
}
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress InvalidReturnType
*/
public function retrieveValue(string $variableName)
{
$value = getenv($variableName);
if ($value === false) {
$value = $_SERVER[$variableName] ?? null;
}
return $value;
}
}
|