[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Http/ -> Http.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Http;
  11  
  12  use Joomla\Http\Http as FrameworkHttp;
  13  use Joomla\Http\TransportInterface as FrameworkTransportInterface;
  14  
  15  // phpcs:disable PSR1.Files.SideEffects
  16  \defined('JPATH_PLATFORM') or die;
  17  // phpcs:enable PSR1.Files.SideEffects
  18  
  19  /**
  20   * HTTP client class.
  21   *
  22   * @since  1.7.3
  23   */
  24  class Http extends FrameworkHttp
  25  {
  26      /**
  27       * Constructor.
  28       *
  29       * @param   array|\ArrayAccess           $options    Client options array. If the registry contains any headers.* elements,
  30       *                                                   these will be added to the request headers.
  31       * @param   FrameworkTransportInterface  $transport  The HTTP transport object.
  32       *
  33       * @since   1.7.3
  34       * @throws  \InvalidArgumentException
  35       */
  36      public function __construct($options = [], FrameworkTransportInterface $transport = null)
  37      {
  38          if (!\is_array($options) && !($options instanceof \ArrayAccess)) {
  39              throw new \InvalidArgumentException(
  40                  'The options param must be an array or implement the ArrayAccess interface.'
  41              );
  42          }
  43  
  44          $this->options = $options;
  45  
  46          if (!isset($transport)) {
  47              $transport = HttpFactory::getAvailableDriver($this->options);
  48          }
  49  
  50          // Ensure the transport is a framework TransportInterface instance or bail out
  51          if (!($transport instanceof FrameworkTransportInterface)) {
  52              throw new \InvalidArgumentException('A valid TransportInterface object was not set.');
  53          }
  54  
  55          $this->transport = $transport;
  56      }
  57  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer