vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/AbstractNamespace.php line 56

Open in your IDE?
  1. <?php
  2. /**
  3.  * Elasticsearch PHP client
  4.  *
  5.  * @link      https://github.com/elastic/elasticsearch-php/
  6.  * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
  7.  * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  8.  * @license   https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
  9.  *
  10.  * Licensed to Elasticsearch B.V under one or more agreements.
  11.  * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
  12.  * the GNU Lesser General Public License, Version 2.1, at your option.
  13.  * See the LICENSE file in the project root for more information.
  14.  */
  15. declare(strict_types 1);
  16. namespace Elasticsearch\Namespaces;
  17. use Elasticsearch\Endpoints\AbstractEndpoint;
  18. use Elasticsearch\Transport;
  19. abstract class AbstractNamespace
  20. {
  21.     /**
  22.      * @var \Elasticsearch\Transport
  23.      */
  24.     protected $transport;
  25.     /**
  26.      * @var callable
  27.      */
  28.     protected $endpoints;
  29.     public function __construct(Transport $transport, callable $endpoints)
  30.     {
  31.         $this->transport $transport;
  32.         $this->endpoints $endpoints;
  33.     }
  34.     /**
  35.      * @return null|mixed
  36.      */
  37.     public function extractArgument(array &$paramsstring $arg)
  38.     {
  39.         if (array_key_exists($arg$params) === true) {
  40.             $val $params[$arg];
  41.             unset($params[$arg]);
  42.             return $val;
  43.         } else {
  44.             return null;
  45.         }
  46.     }
  47.     protected function performRequest(AbstractEndpoint $endpoint)
  48.     {
  49.         $response $this->transport->performRequest(
  50.             $endpoint->getMethod(),
  51.             $endpoint->getURI(),
  52.             $endpoint->getParams(),
  53.             $endpoint->getBody(),
  54.             $endpoint->getOptions()
  55.         );
  56.         return $this->transport->resultOrFuture($response$endpoint->getOptions());
  57.     }
  58. }