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    /**
20     * @param callable $callback
21     */
22    public function __construct(callable $callback)
23    {
24        $this->_callback = $callback;
25    }
26
27    /**
28     * {@inheritdoc}
29     */
30    public function getConnection(array $connections): Connection
31    {
32        return \call_user_func_array($this->_callback, [$connections]);
33    }
34}
35