[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/includes/vendor/maxmind/web-service-common/src/WebService/Http/ -> RequestFactory.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace MaxMind\WebService\Http;
   6  
   7  /**
   8   * Class RequestFactory.
   9   *
  10   * @internal
  11   */
  12  class RequestFactory
  13  {
  14      /**
  15       * Keep the cURL resource here, so that if there are multiple API requests
  16       * done the connection is kept alive, SSL resumption can be used
  17       * etcetera.
  18       *
  19       * @var \CurlHandle|null
  20       */
  21      private $ch;
  22  
  23      public function __destruct()
  24      {
  25          if (!empty($this->ch)) {
  26              curl_close($this->ch);
  27          }
  28      }
  29  
  30      /**
  31       * @return \CurlHandle
  32       */
  33      private function getCurlHandle()
  34      {
  35          if (empty($this->ch)) {
  36              $this->ch = curl_init();
  37          }
  38  
  39          return $this->ch;
  40      }
  41  
  42      public function request(string $url, array $options): Request
  43      {
  44          $options['curlHandle'] = $this->getCurlHandle();
  45  
  46          return new CurlRequest($url, $options);
  47      }
  48  }


Generated: Thu Sep 19 05:10:04 2024 Cross-referenced by PHPXref 0.7.1