1<?php
2
3namespace Elastica\Connection\Strategy;
4
5use Elastica\Connection;
6
7/**
8 * Description of CallbackStrategy.
9 *
10 * @author chabior
11 */
12class CallbackStrategy implements StrategyInterface
13{
14    /**
15     * @var callable
16     */
17    protected $_callback;
18
19    public function __construct(callable $callback)
20    {
21        $this->_callback = $callback;
22    }
23
24    /**
25     * {@inheritdoc}
26     */
27    public function getConnection(array $connections): Connection
28    {
29        return ($this->_callback)($connections);
30    }
31}
32