| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class ConfigTracerProvider implements TracerProviderInterface |
||
| 12 | { |
||
| 13 | /** @var TracerInterface[] */ |
||
| 14 | private array $drivers = []; |
||
| 15 | |||
| 16 | public function __construct( |
||
| 17 | private readonly TelemetryConfig $config, |
||
| 18 | private readonly FactoryInterface $factory |
||
| 19 | ) { |
||
| 20 | } |
||
| 21 | |||
| 22 | public function getTracer(?string $name = null): TracerInterface |
||
| 23 | { |
||
| 24 | $name ??= $this->config->getDefaultDriver(); |
||
| 25 | |||
| 26 | if (isset($this->drivers[$name])) { |
||
| 27 | return $this->drivers[$name]; |
||
| 28 | } |
||
| 29 | |||
| 30 | return $this->drivers[$name] = $this->resolve($name); |
||
| 31 | } |
||
| 32 | |||
| 33 | private function resolve(string $name): TracerInterface |
||
| 42 | } |
||
| 43 | } |
||
| 44 |