|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace OpenTelemetry\API\Configuration\ConfigEnv; |
| 6 | + |
| 7 | +/** |
| 8 | + * Helper class to access environment-based configuration. |
| 9 | + */ |
| 10 | +interface EnvResolver |
| 11 | +{ |
| 12 | + /** |
| 13 | + * Resolves a string-valued environment variable. |
| 14 | + * |
| 15 | + * @param string $name environment variable name |
| 16 | + * @return string|null value of the environment variable, or null if not set or invalid |
| 17 | + * |
| 18 | + * @see https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#string |
| 19 | + */ |
| 20 | + public function string(string $name): ?string; |
| 21 | + |
| 22 | + /** |
| 23 | + * Resolves an enum-valued environment variable. |
| 24 | + * |
| 25 | + * @param string $name environment variable name |
| 26 | + * @param list<string> $values list of permissible enum values |
| 27 | + * @return string|null value of the environment variable, of null if not set or invalid |
| 28 | + * |
| 29 | + * @see https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#enum |
| 30 | + */ |
| 31 | + public function enum(string $name, array $values): ?string; |
| 32 | + |
| 33 | + /** |
| 34 | + * Resolves a boolean-valued environment variable. |
| 35 | + * |
| 36 | + * Allowed values: |
| 37 | + * - case-insensitive "true" |
| 38 | + * - case-insensitive "false" |
| 39 | + * |
| 40 | + * @param string $name environment variable name |
| 41 | + * @return bool|null value of the environment variable, or null if not set or invalid |
| 42 | + * |
| 43 | + * @see https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#boolean-value |
| 44 | + */ |
| 45 | + public function bool(string $name): ?bool; |
| 46 | + |
| 47 | + /** |
| 48 | + * Resolves an integer-valued environment variable. |
| 49 | + * |
| 50 | + * @param string $name environment variable name |
| 51 | + * @param int|null $min lower limit (inclusive), defaults to 0 |
| 52 | + * @param int|null $max upper limit (inclusive), defaults to 2^31-1 |
| 53 | + * @return int|null value of the environment variable, or null if not set or invalid |
| 54 | + * |
| 55 | + * @see https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#numeric-value |
| 56 | + */ |
| 57 | + public function int(string $name, ?int $min = 0, ?int $max = ~(-1 << 31)): int|null; |
| 58 | + |
| 59 | + /** |
| 60 | + * Resolves a numeric-valued environment variable. |
| 61 | + * |
| 62 | + * @param string $name environment variable name |
| 63 | + * @param int|float|null $min lower limit (inclusive), defaults to 0 |
| 64 | + * @param int|float|null $max upper limit (inclusive), defaults to 2^31-1 |
| 65 | + * @return int|float|null value of the environment variable, or null if not set or invalid |
| 66 | + * |
| 67 | + * @see https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#numeric-value |
| 68 | + */ |
| 69 | + public function numeric(string $name, int|float|null $min = 0, int|float|null $max = ~(-1 << 31)): float|int|null; |
| 70 | + |
| 71 | + /** |
| 72 | + * Resolves a list-valued environment variable. |
| 73 | + * |
| 74 | + * @param string $name environment variable name |
| 75 | + * @return list<string>|null value of the environment variable, or null if not set or invalid |
| 76 | + */ |
| 77 | + public function list(string $name): ?array; |
| 78 | + |
| 79 | + /** |
| 80 | + * Resolves a map-valued environment variable. |
| 81 | + * |
| 82 | + * @param string $name environment variable name |
| 83 | + * @return array<string, string>|null value of the environment variable, or null if not set or invalid |
| 84 | + */ |
| 85 | + public function map(string $name): ?array; |
| 86 | +} |
0 commit comments