| Total Complexity | 6 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Coverage | 76.92% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | final class ConfigTracerFactoryProvider implements TracerFactoryProviderInterface |
||
| 12 | { |
||
| 13 | /** @var TracerFactoryInterface[] */ |
||
| 14 | private array $drivers = []; |
||
| 15 | |||
| 16 | 263 | public function __construct( |
|
| 17 | private readonly TelemetryConfig $config, |
||
| 18 | private readonly FactoryInterface $factory |
||
| 19 | ) { |
||
| 20 | } |
||
| 21 | |||
| 22 | 263 | public function getTracerFactory(?string $name = null): TracerFactoryInterface |
|
| 23 | { |
||
| 24 | 263 | $name ??= $this->config->getDefaultDriver(); |
|
| 25 | |||
| 26 | 263 | if (isset($this->drivers[$name])) { |
|
| 27 | return $this->drivers[$name]; |
||
| 28 | } |
||
| 29 | |||
| 30 | 263 | return $this->drivers[$name] = $this->resolve($name); |
|
| 31 | } |
||
| 32 | |||
| 33 | 263 | private function resolve(string $name): TracerFactoryInterface |
|
| 46 | } |
||
| 47 | } |
||
| 48 |