diff options
Diffstat (limited to 'vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php')
-rw-r--r-- | vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php new file mode 100644 index 000000000..c9a8f3b4e --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php @@ -0,0 +1,41 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Resolver; + +use OpenTelemetry\SDK\Common\Configuration\Configuration; + +/** + * @interal + * @psalm-suppress TypeDoesNotContainType + */ +class PhpIniResolver implements ResolverInterface +{ + private PhpIniAccessor $accessor; + + public function __construct(?PhpIniAccessor $accessor = null) + { + $this->accessor = $accessor ?? new PhpIniAccessor(); + } + + public function retrieveValue(string $variableName) + { + $value = $this->accessor->get($variableName) ?: ''; + if (is_array($value)) { + return implode(',', $value); + } + + return $value; + } + + public function hasVariable(string $variableName): bool + { + $value = $this->accessor->get($variableName); + if ($value === []) { + return false; + } + + return $value !== false && !Configuration::isEmpty($value); + } +} |