Conditions | 4 |
Paths | 7 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
21 | 5 | public function isAvailable(string $serviceName): bool |
|
22 | { |
||
23 | try { |
||
24 | 5 | if ($this->storage->numberOfFailures($serviceName) < $this->maxFailures) { |
|
25 | 2 | return true; |
|
26 | } |
||
27 | |||
28 | 3 | $lastRetry = $this->getLastTryTime(); |
|
29 | 3 | if ($this->now() - $lastRetry > $this->waitTime) { |
|
30 | 1 | $this->storage->resetFailuresCounter($serviceName); |
|
31 | 1 | return true; |
|
32 | } |
||
33 | |||
34 | 2 | return false; |
|
35 | 1 | } catch (StorageException $ex) { |
|
36 | 1 | return true; |
|
37 | } |
||
56 |