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