ttrss/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/PsrClientResolver.php

30 lines
699 B
PHP
Raw Normal View History

2023-10-20 14:12:29 +00:00
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Common\Adapter\HttpDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use OpenTelemetry\SDK\Common\Http\Psr\Client\ResolverInterface;
use Psr\Http\Client\ClientInterface;
final class PsrClientResolver implements ResolverInterface
{
private ?ClientInterface $client;
public function __construct(?ClientInterface $client = null)
{
$this->client = $client;
}
public static function create(?ClientInterface $client = null): self
{
return new self($client);
}
public function resolvePsrClient(): ClientInterface
{
return $this->client ??= Psr18ClientDiscovery::find();
}
}