Conditions | 6 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
18 | public function chooseHttpClient() |
||
19 | { |
||
20 | $last = current($this->clientPool); |
||
21 | |||
22 | do { |
||
23 | $client = next($this->clientPool); |
||
24 | |||
25 | if (false === $client) { |
||
26 | $client = reset($this->clientPool); |
||
27 | |||
28 | if (false === $client) { |
||
29 | throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | // Case when there is only one and the last one has been disabled |
||
34 | if ($last === $client && $client->isDisabled()) { |
||
35 | throw new HttpClientNotFoundException('Cannot choose a http client as there is no one enabled in the pool'); |
||
36 | } |
||
37 | } while ($client->isDisabled()); |
||
38 | |||
39 | return $client; |
||
40 | } |
||
41 | } |
||
42 |