HttpServiceProvider.php 625 B

123456789101112131415161718192021222324
  1. <?php
  2. declare(strict_types=1);
  3. namespace Yansongda\Artful\Service;
  4. use Yansongda\Artful\Artful;
  5. use Yansongda\Artful\Contract\HttpClientFactoryInterface;
  6. use Yansongda\Artful\Contract\ServiceProviderInterface;
  7. use Yansongda\Artful\Exception\ContainerException;
  8. use Yansongda\Artful\HttpClientFactory;
  9. class HttpServiceProvider implements ServiceProviderInterface
  10. {
  11. /**
  12. * @throws ContainerException
  13. */
  14. public function register(mixed $data = null): void
  15. {
  16. $container = Artful::getContainer();
  17. Artful::set(HttpClientFactoryInterface::class, new HttpClientFactory($container));
  18. }
  19. }