RotationChooser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAvailableHost() 0 9 2
1
<?php
2
3
namespace NBN\LoadBalancer\Chooser;
4
5
use NBN\LoadBalancer\Exception\NoRegisteredHostException;
6
use Symfony\Component\HttpFoundation\Request;
7
8
/**
9
 * @author Nicolas Bastien <[email protected]>
10
 */
11
class RotationChooser implements ChooserInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function getAvailableHost(Request $request, array $hosts)
17
    {
18
        if (count($hosts) == 0) {
19
            throw new NoRegisteredHostException();
20
        }
21
22
        //basic random
23
        return $hosts[array_rand($hosts)];
24
    }
25
}
26