RoundRobin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 16
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConnection() 0 5 1
1
<?php
2
3
4
namespace Manticoresearch\Connection\Strategy;
5
6
use Manticoresearch\Connection;
7
8
/**
9
 * Class RoundRobin
10
 * @package Manticoresearch\Connection\Strategy
11
 */
12
class RoundRobin implements SelectorInterface
13
{
14
    /**
15
     * @var int
16
     */
17
    private $current = 0;
18
19
    /**
20
     * @param array $connections
21
     * @return Connection
22
     */
23
    public function getConnection(array $connections) :Connection
24
    {
25
        $connection = $connections[$this->current % count($connections)];
26
        ++$this->current;
27
        return $connection;
28
    }
29
}
30