vendor/ruflin/elastica/src/Connection/Strategy/Simple.php line 13

Open in your IDE?
  1. <?php
  2. namespace Elastica\Connection\Strategy;
  3. use Elastica\Connection;
  4. use Elastica\Exception\ClientException;
  5. /**
  6.  * Description of SimpleStrategy.
  7.  *
  8.  * @author chabior
  9.  */
  10. class Simple implements StrategyInterface
  11. {
  12.     /**
  13.      * {@inheritdoc}
  14.      */
  15.     public function getConnection(array $connections): Connection
  16.     {
  17.         foreach ($connections as $connection) {
  18.             if ($connection->isEnabled()) {
  19.                 return $connection;
  20.             }
  21.         }
  22.         throw new ClientException('No enabled connection');
  23.     }
  24. }